[PATCH linux v1 4/4] arm: dts: Add dt-binding to support seven segment display on zaius

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
Add clock, data and clear signal GPIO lines to control seven segment display on
zaius platform.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts 
b/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
index 8ef4ece..ccb8147 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
@@ -43,6 +43,14 @@
gpios = < ASPEED_GPIO(H, 7) GPIO_ACTIVE_LOW>;
};
};
+
+   seven-seg-disp {
+   compatible = "seven-seg-gpio-dev";
+   refresh-interval-ms = "1000";
+   clock-gpios = < ASPEED_GPIO(J, 0) GPIO_ACTIVE_HIGH>;
+   data-gpios = < ASPEED_GPIO(J, 2) GPIO_ACTIVE_HIGH>;
+   clear-gpios = < ASPEED_GPIO(J, 1) GPIO_ACTIVE_HIGH>;
+   };
 };

  {
--
2.8.0.rc3.226.g39d4020



[PATCH linux v1 4/4] arm: dts: Add dt-binding to support seven segment display on zaius

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
Add clock, data and clear signal GPIO lines to control seven segment display on
zaius platform.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts 
b/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
index 8ef4ece..ccb8147 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
@@ -43,6 +43,14 @@
gpios = < ASPEED_GPIO(H, 7) GPIO_ACTIVE_LOW>;
};
};
+
+   seven-seg-disp {
+   compatible = "seven-seg-gpio-dev";
+   refresh-interval-ms = "1000";
+   clock-gpios = < ASPEED_GPIO(J, 0) GPIO_ACTIVE_HIGH>;
+   data-gpios = < ASPEED_GPIO(J, 2) GPIO_ACTIVE_HIGH>;
+   clear-gpios = < ASPEED_GPIO(J, 1) GPIO_ACTIVE_HIGH>;
+   };
 };

  {
--
2.8.0.rc3.226.g39d4020



[PATCH linux v1 2/4] drivers: misc: Character device driver for seven segment display

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
Character device driver which implements the user-space
API for letting a user write to two 7-segment displays including
any conversion methods necessary to map the user input
to two 7-segment displays.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 drivers/misc/Kconfig  |   8 ++
 drivers/misc/Makefile |   1 +
 drivers/misc/seven_seg_disp.c | 197 ++
 drivers/misc/seven_seg_disp.h |  34 
 4 files changed, 240 insertions(+)
 create mode 100644 drivers/misc/seven_seg_disp.c
 create mode 100644 drivers/misc/seven_seg_disp.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a216b46..a21aec1 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -791,6 +791,14 @@ config PANEL_CHANGE_MESSAGE
  If you say 'Y' here, you'll be able to choose a message yourself. 
Otherwise,
  say 'N' and keep the default message with the version.

+config SEVEN_SEGMENT_DISPLAY
+   tristate "Character driver for seven segment display support"
+   help
+ Character device driver which implements the user-space
+ API for letting a user write to two 7-segment displays including
+ any conversion methods necessary to map the user input
+ to two 7-segment displays.
+
 config PANEL_BOOT_MESSAGE
depends on PANEL && PANEL_CHANGE_MESSAGE="y"
string "New initialization message"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b2fb6dbf..c2defbd 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -56,4 +56,5 @@ obj-$(CONFIG_GENWQE)  += genwqe/
 obj-$(CONFIG_ECHO) += echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)  += vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE) += cxl/
+obj-$(CONFIG_SEVEN_SEGMENT_DISPLAY)+= seven_seg_disp.o
 obj-$(CONFIG_PANEL) += panel.o
diff --git a/drivers/misc/seven_seg_disp.c b/drivers/misc/seven_seg_disp.c
new file mode 100644
index 000..4daeac5
--- /dev/null
+++ b/drivers/misc/seven_seg_disp.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 or later as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "seven_seg_disp.h"
+
+#define LED_DOT 0x01
+
+/*
+ * 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+ *  _   _   _   _   _   _   _   _   _   _   _   _
+ * | |   |  _|  _| |_| |_  |_| |_| |_| |_| |_  |_| |_  |_
+ * |_|   | |_   _|   |  _| |_|   | |_|   | | | |_| |_  |_| |_  |
+ *
+ * data[7:1] = led[a:g]
+ */
+const u8 seven_seg_bits[] = {
+   0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0,
+   0xFE, 0xF6, 0xEE, 0x3E, 0x9C, 0x7A, 0x9E, 0x8E
+   };
+
+/*
+ * 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+ *  _   _   _  __
+ * |   |_  |_| |_  _   _   _   _   _   _   _  |__|  _| | |
+ * |_  |_  |   |   _|  |_| |_| | |
+ *
+ * data[7:1] = led[a:g]
+ */
+const u8 special_seven_seg_bits[] = {
+   0x00, 0x9C, 0x1E, 0xCE, 0x8E, 0x02, 0x02, 0x02,
+   0x02, 0x02, 0x02, 0x02, 0xB6, 0x7A, 0x7A, 0xEC
+   };
+
+static dev_t seven_seg_devno;
+static struct class *seven_seg_disp_class;
+
+static int seven_seg_disp_open(struct inode *inode, struct file *filp)
+{
+   struct seven_seg_disp_dev *disp_dev;
+
+   disp_dev = container_of(inode->i_cdev,
+struct seven_seg_disp_dev, cdev);
+   filp->private_data = disp_dev;
+   return 0;
+}
+
+static int seven_seg_disp_close(struct inode *inode, struct file *filp)
+{
+   filp->private_data = NULL;
+   return 0;
+}
+
+static ssize_t seven_seg_disp_read(struct file *filp, char __user *buf, size_t
+   len, loff_t *off)
+{
+   struct seven_seg_disp_dev *disp_dev = filp->private_data;
+
+   if (disp_dev->disp_data_valid)
+   return -EINVAL;
+
+   if (copy_to_user(buf, disp_dev->seven_seg_disp_data_array,
+   MAX_DISP_CHAR_SIZE) != 0) {
+   return -EFAULT;
+   }
+
+   return 0;
+}
+
+static u16 convert_to_disp_data(char *buf)
+{
+   u8 low_display;
+   u8 high_display;
+   u16 led_value;
+
+   low_display = seven_seg_bits[hex_to_bin(buf[2])];
+
+   high_display = (buf[0] == '1') ?
+   special_seven_seg_bits[hex_to_bin(buf[1])] :
+   seven_seg_bits[hex_to_bin(buf[1])];
+
+   led_value = low_display | (high_display << 8);
+   if (buf[0] == '1')
+   led_value |= LED_DOT | (LED_DOT << 8);
+
+   return led_value;
+}
+
+static ssize_t seven_seg_disp_write(struct file *filp, const char __user *buf,
+   

[PATCH] vhost: introduce O(1) vq metadata cache

2016-12-13 Thread Jason Wang
When device IOTLB is enabled, all address translations were stored in
interval tree. O(lgN) searching time could be slow for virtqueue
metadata (avail, used and descriptors) since they were accessed much
often than other addresses. So this patch introduces an O(1) array
which points to the interval tree nodes that store the translations of
vq metadata. Those array were update during vq IOTLB prefetching and
were reset during each invalidation and tlb update. Each time we want
to access vq metadata, this small array were queried before interval
tree. This would be sufficient for static mappings but not dynamic
mappings, we could do optimizations on top.

Test were done with l2fwd in guest (2M hugepage):

   noiommu  | before| after
tx 1.32Mpps | 1.06Mpps(82%) | 1.30Mpps(98%)
rx 2.33Mpps | 1.46Mpps(63%) | 2.29Mpps(98%)

We can almost reach the same performance as noiommu mode.

Signed-off-by: Jason Wang 
---
 drivers/vhost/vhost.c | 136 --
 drivers/vhost/vhost.h |   8 +++
 2 files changed, 118 insertions(+), 26 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index c6f2d89..89e40b6 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -282,6 +282,22 @@ void vhost_poll_queue(struct vhost_poll *poll)
 }
 EXPORT_SYMBOL_GPL(vhost_poll_queue);
 
+static void __vhost_vq_meta_reset(struct vhost_virtqueue *vq)
+{
+   int j;
+
+   for (j = 0; j < VHOST_NUM_ADDRS; j++)
+   vq->meta_iotlb[j] = NULL;
+}
+
+static void vhost_vq_meta_reset(struct vhost_dev *d)
+{
+   int i;
+
+   for (i = 0; i < d->nvqs; ++i)
+   __vhost_vq_meta_reset(d->vqs[i]);
+}
+
 static void vhost_vq_reset(struct vhost_dev *dev,
   struct vhost_virtqueue *vq)
 {
@@ -311,6 +327,7 @@ static void vhost_vq_reset(struct vhost_dev *dev,
vq->busyloop_timeout = 0;
vq->umem = NULL;
vq->iotlb = NULL;
+   __vhost_vq_meta_reset(vq);
 }
 
 static int vhost_worker(void *data)
@@ -690,6 +707,18 @@ static int vq_memory_access_ok(void __user *log_base, 
struct vhost_umem *umem,
return 1;
 }
 
+static inline void __user *vhost_vq_meta_fetch(struct vhost_virtqueue *vq,
+  u64 addr, unsigned int size,
+  int type)
+{
+   const struct vhost_umem_node *node = vq->meta_iotlb[type];
+
+   if (!node)
+   return NULL;
+
+   return (void *)(node->userspace_addr + (u64)addr - node->start);
+}
+
 /* Can we switch to this memory table? */
 /* Caller should have device mutex but not vq mutex */
 static int memory_access_ok(struct vhost_dev *d, struct vhost_umem *umem,
@@ -732,8 +761,14 @@ static int vhost_copy_to_user(struct vhost_virtqueue *vq, 
void *to,
 * could be access through iotlb. So -EAGAIN should
 * not happen in this case.
 */
-   /* TODO: more fast path */
struct iov_iter t;
+   void __user *uaddr = vhost_vq_meta_fetch(vq,
+(u64)(uintptr_t)to, size,
+VHOST_ADDR_DESC);
+
+   if (uaddr)
+   return __copy_to_user(uaddr, from, size);
+
ret = translate_desc(vq, (u64)(uintptr_t)to, size, 
vq->iotlb_iov,
 ARRAY_SIZE(vq->iotlb_iov),
 VHOST_ACCESS_WO);
@@ -761,8 +796,14 @@ static int vhost_copy_from_user(struct vhost_virtqueue 
*vq, void *to,
 * could be access through iotlb. So -EAGAIN should
 * not happen in this case.
 */
-   /* TODO: more fast path */
+   void __user *uaddr = vhost_vq_meta_fetch(vq,
+(u64)(uintptr_t)from, size,
+VHOST_ADDR_DESC);
struct iov_iter f;
+
+   if (uaddr)
+   return __copy_from_user(to, uaddr, size);
+
ret = translate_desc(vq, (u64)(uintptr_t)from, size, 
vq->iotlb_iov,
 ARRAY_SIZE(vq->iotlb_iov),
 VHOST_ACCESS_RO);
@@ -782,17 +823,12 @@ static int vhost_copy_from_user(struct vhost_virtqueue 
*vq, void *to,
return ret;
 }
 
-static void __user *__vhost_get_user(struct vhost_virtqueue *vq,
-void *addr, unsigned size)
+static void __user *__vhost_get_user_slow(struct vhost_virtqueue *vq,
+ void *addr, unsigned int size,
+ int type)
 {
int ret;
 
-   /* This function should be called after iotlb
-* prefetch, which means we're sure that vq
-* could be access through iotlb. So -EAGAIN should
-* not happen in this case.
- 

[PATCH] vhost: introduce O(1) vq metadata cache

2016-12-13 Thread Jason Wang
When device IOTLB is enabled, all address translations were stored in
interval tree. O(lgN) searching time could be slow for virtqueue
metadata (avail, used and descriptors) since they were accessed much
often than other addresses. So this patch introduces an O(1) array
which points to the interval tree nodes that store the translations of
vq metadata. Those array were update during vq IOTLB prefetching and
were reset during each invalidation and tlb update. Each time we want
to access vq metadata, this small array were queried before interval
tree. This would be sufficient for static mappings but not dynamic
mappings, we could do optimizations on top.

Test were done with l2fwd in guest (2M hugepage):

   noiommu  | before| after
tx 1.32Mpps | 1.06Mpps(82%) | 1.30Mpps(98%)
rx 2.33Mpps | 1.46Mpps(63%) | 2.29Mpps(98%)

We can almost reach the same performance as noiommu mode.

Signed-off-by: Jason Wang 
---
 drivers/vhost/vhost.c | 136 --
 drivers/vhost/vhost.h |   8 +++
 2 files changed, 118 insertions(+), 26 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index c6f2d89..89e40b6 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -282,6 +282,22 @@ void vhost_poll_queue(struct vhost_poll *poll)
 }
 EXPORT_SYMBOL_GPL(vhost_poll_queue);
 
+static void __vhost_vq_meta_reset(struct vhost_virtqueue *vq)
+{
+   int j;
+
+   for (j = 0; j < VHOST_NUM_ADDRS; j++)
+   vq->meta_iotlb[j] = NULL;
+}
+
+static void vhost_vq_meta_reset(struct vhost_dev *d)
+{
+   int i;
+
+   for (i = 0; i < d->nvqs; ++i)
+   __vhost_vq_meta_reset(d->vqs[i]);
+}
+
 static void vhost_vq_reset(struct vhost_dev *dev,
   struct vhost_virtqueue *vq)
 {
@@ -311,6 +327,7 @@ static void vhost_vq_reset(struct vhost_dev *dev,
vq->busyloop_timeout = 0;
vq->umem = NULL;
vq->iotlb = NULL;
+   __vhost_vq_meta_reset(vq);
 }
 
 static int vhost_worker(void *data)
@@ -690,6 +707,18 @@ static int vq_memory_access_ok(void __user *log_base, 
struct vhost_umem *umem,
return 1;
 }
 
+static inline void __user *vhost_vq_meta_fetch(struct vhost_virtqueue *vq,
+  u64 addr, unsigned int size,
+  int type)
+{
+   const struct vhost_umem_node *node = vq->meta_iotlb[type];
+
+   if (!node)
+   return NULL;
+
+   return (void *)(node->userspace_addr + (u64)addr - node->start);
+}
+
 /* Can we switch to this memory table? */
 /* Caller should have device mutex but not vq mutex */
 static int memory_access_ok(struct vhost_dev *d, struct vhost_umem *umem,
@@ -732,8 +761,14 @@ static int vhost_copy_to_user(struct vhost_virtqueue *vq, 
void *to,
 * could be access through iotlb. So -EAGAIN should
 * not happen in this case.
 */
-   /* TODO: more fast path */
struct iov_iter t;
+   void __user *uaddr = vhost_vq_meta_fetch(vq,
+(u64)(uintptr_t)to, size,
+VHOST_ADDR_DESC);
+
+   if (uaddr)
+   return __copy_to_user(uaddr, from, size);
+
ret = translate_desc(vq, (u64)(uintptr_t)to, size, 
vq->iotlb_iov,
 ARRAY_SIZE(vq->iotlb_iov),
 VHOST_ACCESS_WO);
@@ -761,8 +796,14 @@ static int vhost_copy_from_user(struct vhost_virtqueue 
*vq, void *to,
 * could be access through iotlb. So -EAGAIN should
 * not happen in this case.
 */
-   /* TODO: more fast path */
+   void __user *uaddr = vhost_vq_meta_fetch(vq,
+(u64)(uintptr_t)from, size,
+VHOST_ADDR_DESC);
struct iov_iter f;
+
+   if (uaddr)
+   return __copy_from_user(to, uaddr, size);
+
ret = translate_desc(vq, (u64)(uintptr_t)from, size, 
vq->iotlb_iov,
 ARRAY_SIZE(vq->iotlb_iov),
 VHOST_ACCESS_RO);
@@ -782,17 +823,12 @@ static int vhost_copy_from_user(struct vhost_virtqueue 
*vq, void *to,
return ret;
 }
 
-static void __user *__vhost_get_user(struct vhost_virtqueue *vq,
-void *addr, unsigned size)
+static void __user *__vhost_get_user_slow(struct vhost_virtqueue *vq,
+ void *addr, unsigned int size,
+ int type)
 {
int ret;
 
-   /* This function should be called after iotlb
-* prefetch, which means we're sure that vq
-* could be access through iotlb. So -EAGAIN should
-* not happen in this case.
-*/
-   /* 

[PATCH linux v1 2/4] drivers: misc: Character device driver for seven segment display

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
Character device driver which implements the user-space
API for letting a user write to two 7-segment displays including
any conversion methods necessary to map the user input
to two 7-segment displays.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 drivers/misc/Kconfig  |   8 ++
 drivers/misc/Makefile |   1 +
 drivers/misc/seven_seg_disp.c | 197 ++
 drivers/misc/seven_seg_disp.h |  34 
 4 files changed, 240 insertions(+)
 create mode 100644 drivers/misc/seven_seg_disp.c
 create mode 100644 drivers/misc/seven_seg_disp.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a216b46..a21aec1 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -791,6 +791,14 @@ config PANEL_CHANGE_MESSAGE
  If you say 'Y' here, you'll be able to choose a message yourself. 
Otherwise,
  say 'N' and keep the default message with the version.

+config SEVEN_SEGMENT_DISPLAY
+   tristate "Character driver for seven segment display support"
+   help
+ Character device driver which implements the user-space
+ API for letting a user write to two 7-segment displays including
+ any conversion methods necessary to map the user input
+ to two 7-segment displays.
+
 config PANEL_BOOT_MESSAGE
depends on PANEL && PANEL_CHANGE_MESSAGE="y"
string "New initialization message"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b2fb6dbf..c2defbd 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -56,4 +56,5 @@ obj-$(CONFIG_GENWQE)  += genwqe/
 obj-$(CONFIG_ECHO) += echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)  += vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE) += cxl/
+obj-$(CONFIG_SEVEN_SEGMENT_DISPLAY)+= seven_seg_disp.o
 obj-$(CONFIG_PANEL) += panel.o
diff --git a/drivers/misc/seven_seg_disp.c b/drivers/misc/seven_seg_disp.c
new file mode 100644
index 000..4daeac5
--- /dev/null
+++ b/drivers/misc/seven_seg_disp.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 or later as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "seven_seg_disp.h"
+
+#define LED_DOT 0x01
+
+/*
+ * 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+ *  _   _   _   _   _   _   _   _   _   _   _   _
+ * | |   |  _|  _| |_| |_  |_| |_| |_| |_| |_  |_| |_  |_
+ * |_|   | |_   _|   |  _| |_|   | |_|   | | | |_| |_  |_| |_  |
+ *
+ * data[7:1] = led[a:g]
+ */
+const u8 seven_seg_bits[] = {
+   0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0,
+   0xFE, 0xF6, 0xEE, 0x3E, 0x9C, 0x7A, 0x9E, 0x8E
+   };
+
+/*
+ * 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+ *  _   _   _  __
+ * |   |_  |_| |_  _   _   _   _   _   _   _  |__|  _| | |
+ * |_  |_  |   |   _|  |_| |_| | |
+ *
+ * data[7:1] = led[a:g]
+ */
+const u8 special_seven_seg_bits[] = {
+   0x00, 0x9C, 0x1E, 0xCE, 0x8E, 0x02, 0x02, 0x02,
+   0x02, 0x02, 0x02, 0x02, 0xB6, 0x7A, 0x7A, 0xEC
+   };
+
+static dev_t seven_seg_devno;
+static struct class *seven_seg_disp_class;
+
+static int seven_seg_disp_open(struct inode *inode, struct file *filp)
+{
+   struct seven_seg_disp_dev *disp_dev;
+
+   disp_dev = container_of(inode->i_cdev,
+struct seven_seg_disp_dev, cdev);
+   filp->private_data = disp_dev;
+   return 0;
+}
+
+static int seven_seg_disp_close(struct inode *inode, struct file *filp)
+{
+   filp->private_data = NULL;
+   return 0;
+}
+
+static ssize_t seven_seg_disp_read(struct file *filp, char __user *buf, size_t
+   len, loff_t *off)
+{
+   struct seven_seg_disp_dev *disp_dev = filp->private_data;
+
+   if (disp_dev->disp_data_valid)
+   return -EINVAL;
+
+   if (copy_to_user(buf, disp_dev->seven_seg_disp_data_array,
+   MAX_DISP_CHAR_SIZE) != 0) {
+   return -EFAULT;
+   }
+
+   return 0;
+}
+
+static u16 convert_to_disp_data(char *buf)
+{
+   u8 low_display;
+   u8 high_display;
+   u16 led_value;
+
+   low_display = seven_seg_bits[hex_to_bin(buf[2])];
+
+   high_display = (buf[0] == '1') ?
+   special_seven_seg_bits[hex_to_bin(buf[1])] :
+   seven_seg_bits[hex_to_bin(buf[1])];
+
+   led_value = low_display | (high_display << 8);
+   if (buf[0] == '1')
+   led_value |= LED_DOT | (LED_DOT << 8);
+
+   return led_value;
+}
+
+static ssize_t seven_seg_disp_write(struct file *filp, const char __user *buf,
+ 

[PATCH linux v1 3/4] drivers: misc: Platform driver for seven segment display support

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
Platform device driver which provides an API for displaying on two
7-segment displays, and implements the required bit-banging.
The hardware assumed is 74HC164 wired to two 7-segment displays.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 drivers/misc/Kconfig  |   8 ++
 drivers/misc/Makefile |   1 +
 drivers/misc/seven_seg_gpio.c | 206 ++
 3 files changed, 215 insertions(+)
 create mode 100644 drivers/misc/seven_seg_gpio.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a21aec1..6508108 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -812,6 +812,14 @@ config PANEL_BOOT_MESSAGE
  An empty message will only clear the display at driver init time. Any 
other
  printf()-formatted message is valid with newline and escape codes.

+config SEVEN_SEGMENT_GPIO
+   tristate "Platform driver to update seven segment display"
+   depends on SEVEN_SEGMENT_DISPLAY
+   help
+ Platform device driver which provides an API for displaying on two
+ 7-segment displays, and implements the required bit-banging.
+ The hardware assumed is 74HC164 wired to two 7-segment displays.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index c2defbd..d9c0d20 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -58,3 +58,4 @@ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE) += cxl/
 obj-$(CONFIG_SEVEN_SEGMENT_DISPLAY)+= seven_seg_disp.o
 obj-$(CONFIG_PANEL) += panel.o
+obj-$(CONFIG_SEVEN_SEGMENT_GPIO)   += seven_seg_gpio.o
diff --git a/drivers/misc/seven_seg_gpio.c b/drivers/misc/seven_seg_gpio.c
new file mode 100644
index 000..3dcb903
--- /dev/null
+++ b/drivers/misc/seven_seg_gpio.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 or later as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "seven_seg_disp.h"
+
+#define DELAY_INTVL_US 1
+
+#define CLOCK_GPIO_NAME "clock"
+#define DATA_GPIO_NAME "data"
+#define CLEAR_GPIO_NAME "clear"
+
+struct seven_seg_gpio_info {
+   u16 curr_disp_value;
+   u16 refresh_interval;
+   struct timer_list update_timer;
+   struct gpio_desc *clock_gpio;
+   struct gpio_desc *data_gpio;
+   struct gpio_desc *clear_gpio;
+};
+
+static void update_seven_seg_gpio_data(struct device *dev, u16 data)
+{
+   struct platform_device *pdev;
+   struct seven_seg_gpio_info *gpio_info;
+
+   pdev = container_of(dev, struct platform_device, dev);
+   if (pdev == NULL) {
+   pr_err("invalid NULL platform_device\n");
+   return;
+   }
+
+   gpio_info = platform_get_drvdata(pdev);
+   if (gpio_info == NULL) {
+   pr_err("invalid NULL gpio_info\n");
+   return;
+   }
+
+   gpio_info->curr_disp_value = data;
+}
+
+static void clear_seven_seg_gpio_data(struct device *dev, u16 data)
+{
+   struct platform_device *pdev;
+   struct seven_seg_gpio_info *gpio_info;
+
+   pdev = container_of(dev, struct platform_device, dev);
+   if (pdev == NULL) {
+   pr_err("invalid NULL platform_device\n");
+   return;
+   }
+
+   gpio_info = platform_get_drvdata(pdev);
+   if (gpio_info == NULL) {
+   pr_err("invalid NULL gpio_info\n");
+   return;
+   }
+
+   gpio_info->curr_disp_value = 0;
+}
+
+static void send_seven_seg_gpio_data(u16 disp_data,
+   struct seven_seg_gpio_info *gpio_info)
+{
+   int i;
+
+   gpiod_set_value(gpio_info->clear_gpio, 0);
+   udelay(DELAY_INTVL_US);
+   gpiod_set_value(gpio_info->clear_gpio, 1);
+   udelay(DELAY_INTVL_US);
+
+   for (i = 0; i < 16; i++) {
+   if (disp_data & 0x01)
+   gpiod_set_value(gpio_info->data_gpio, 1);
+   else
+   gpiod_set_value(gpio_info->data_gpio, 0);
+
+   udelay(DELAY_INTVL_US);
+
+   gpiod_set_value(gpio_info->clock_gpio, 0);
+   udelay(DELAY_INTVL_US);
+   gpiod_set_value(gpio_info->clock_gpio, 1);
+   udelay(DELAY_INTVL_US);
+
+   disp_data >>= 1;
+   }
+}
+
+static void disp_refresh_timer_handler(unsigned long data)
+{
+   u16 disp_data;
+   struct seven_seg_gpio_info *gpio_info =
+   (struct seven_seg_gpio_info *)data;
+   disp_data = gpio_info->curr_disp_value;
+
+   send_seven_seg_gpio_data(disp_data, gpio_info);
+   

[PATCH linux v1 1/4] Documentation: dt-bindings: Document bindings for seven segment display support

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
This binding provides interface for adding clock, data and clear signal GPIO
lines to control seven segment display.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 .../devicetree/bindings/misc/seven-seg-gpio.txt| 27 ++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/seven-seg-gpio.txt

diff --git a/Documentation/devicetree/bindings/misc/seven-seg-gpio.txt 
b/Documentation/devicetree/bindings/misc/seven-seg-gpio.txt
new file mode 100644
index 000..9a4e255
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/seven-seg-gpio.txt
@@ -0,0 +1,27 @@
+This binding defines interface to add clock, data and clear GPIO lines required
+for seven segment display support.
+
+Required properties:
+- compatible : should be "seven-seg-gpio-dev".
+- clock-gpios :  Should specify the GPIO pin connected to the Clock line on the
+  hardware.
+- data-gpios : Should specify the GPIO pin connected to Data line on the
+  hardware.
+- clear-gpios : Should specify the GPIO pin connected to Clear line on the
+  hardware.
+
+Optional properties:
+- refresh-interval-ms : The interval at which to refresh the display.
+  If this property is not present, the default value is 1000.
+
+Examples:
+
+#include 
+
+seven-seg-disp {
+   compatible = "seven-seg-gpio-dev";
+   refresh-interval-ms = "1000";
+   clock-gpios = < 0 GPIO_ACTIVE_LOW>;
+   data-gpios = < 1 GPIO_ACTIVE_HIGH>;
+   clear-gpios = < 2 GPIO_ACTIVE_HIGH>;
+};
--
2.8.0.rc3.226.g39d4020



[PATCH linux v1 3/4] drivers: misc: Platform driver for seven segment display support

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
Platform device driver which provides an API for displaying on two
7-segment displays, and implements the required bit-banging.
The hardware assumed is 74HC164 wired to two 7-segment displays.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 drivers/misc/Kconfig  |   8 ++
 drivers/misc/Makefile |   1 +
 drivers/misc/seven_seg_gpio.c | 206 ++
 3 files changed, 215 insertions(+)
 create mode 100644 drivers/misc/seven_seg_gpio.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a21aec1..6508108 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -812,6 +812,14 @@ config PANEL_BOOT_MESSAGE
  An empty message will only clear the display at driver init time. Any 
other
  printf()-formatted message is valid with newline and escape codes.

+config SEVEN_SEGMENT_GPIO
+   tristate "Platform driver to update seven segment display"
+   depends on SEVEN_SEGMENT_DISPLAY
+   help
+ Platform device driver which provides an API for displaying on two
+ 7-segment displays, and implements the required bit-banging.
+ The hardware assumed is 74HC164 wired to two 7-segment displays.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index c2defbd..d9c0d20 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -58,3 +58,4 @@ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE) += cxl/
 obj-$(CONFIG_SEVEN_SEGMENT_DISPLAY)+= seven_seg_disp.o
 obj-$(CONFIG_PANEL) += panel.o
+obj-$(CONFIG_SEVEN_SEGMENT_GPIO)   += seven_seg_gpio.o
diff --git a/drivers/misc/seven_seg_gpio.c b/drivers/misc/seven_seg_gpio.c
new file mode 100644
index 000..3dcb903
--- /dev/null
+++ b/drivers/misc/seven_seg_gpio.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 or later as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "seven_seg_disp.h"
+
+#define DELAY_INTVL_US 1
+
+#define CLOCK_GPIO_NAME "clock"
+#define DATA_GPIO_NAME "data"
+#define CLEAR_GPIO_NAME "clear"
+
+struct seven_seg_gpio_info {
+   u16 curr_disp_value;
+   u16 refresh_interval;
+   struct timer_list update_timer;
+   struct gpio_desc *clock_gpio;
+   struct gpio_desc *data_gpio;
+   struct gpio_desc *clear_gpio;
+};
+
+static void update_seven_seg_gpio_data(struct device *dev, u16 data)
+{
+   struct platform_device *pdev;
+   struct seven_seg_gpio_info *gpio_info;
+
+   pdev = container_of(dev, struct platform_device, dev);
+   if (pdev == NULL) {
+   pr_err("invalid NULL platform_device\n");
+   return;
+   }
+
+   gpio_info = platform_get_drvdata(pdev);
+   if (gpio_info == NULL) {
+   pr_err("invalid NULL gpio_info\n");
+   return;
+   }
+
+   gpio_info->curr_disp_value = data;
+}
+
+static void clear_seven_seg_gpio_data(struct device *dev, u16 data)
+{
+   struct platform_device *pdev;
+   struct seven_seg_gpio_info *gpio_info;
+
+   pdev = container_of(dev, struct platform_device, dev);
+   if (pdev == NULL) {
+   pr_err("invalid NULL platform_device\n");
+   return;
+   }
+
+   gpio_info = platform_get_drvdata(pdev);
+   if (gpio_info == NULL) {
+   pr_err("invalid NULL gpio_info\n");
+   return;
+   }
+
+   gpio_info->curr_disp_value = 0;
+}
+
+static void send_seven_seg_gpio_data(u16 disp_data,
+   struct seven_seg_gpio_info *gpio_info)
+{
+   int i;
+
+   gpiod_set_value(gpio_info->clear_gpio, 0);
+   udelay(DELAY_INTVL_US);
+   gpiod_set_value(gpio_info->clear_gpio, 1);
+   udelay(DELAY_INTVL_US);
+
+   for (i = 0; i < 16; i++) {
+   if (disp_data & 0x01)
+   gpiod_set_value(gpio_info->data_gpio, 1);
+   else
+   gpiod_set_value(gpio_info->data_gpio, 0);
+
+   udelay(DELAY_INTVL_US);
+
+   gpiod_set_value(gpio_info->clock_gpio, 0);
+   udelay(DELAY_INTVL_US);
+   gpiod_set_value(gpio_info->clock_gpio, 1);
+   udelay(DELAY_INTVL_US);
+
+   disp_data >>= 1;
+   }
+}
+
+static void disp_refresh_timer_handler(unsigned long data)
+{
+   u16 disp_data;
+   struct seven_seg_gpio_info *gpio_info =
+   (struct seven_seg_gpio_info *)data;
+   disp_data = gpio_info->curr_disp_value;
+
+   send_seven_seg_gpio_data(disp_data, gpio_info);
+   mod_timer(_info->update_timer,
+   

[PATCH linux v1 1/4] Documentation: dt-bindings: Document bindings for seven segment display support

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
This binding provides interface for adding clock, data and clear signal GPIO
lines to control seven segment display.

Signed-off-by: Jaghathiswari Rankappagounder Natarajan 
---
 .../devicetree/bindings/misc/seven-seg-gpio.txt| 27 ++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/seven-seg-gpio.txt

diff --git a/Documentation/devicetree/bindings/misc/seven-seg-gpio.txt 
b/Documentation/devicetree/bindings/misc/seven-seg-gpio.txt
new file mode 100644
index 000..9a4e255
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/seven-seg-gpio.txt
@@ -0,0 +1,27 @@
+This binding defines interface to add clock, data and clear GPIO lines required
+for seven segment display support.
+
+Required properties:
+- compatible : should be "seven-seg-gpio-dev".
+- clock-gpios :  Should specify the GPIO pin connected to the Clock line on the
+  hardware.
+- data-gpios : Should specify the GPIO pin connected to Data line on the
+  hardware.
+- clear-gpios : Should specify the GPIO pin connected to Clear line on the
+  hardware.
+
+Optional properties:
+- refresh-interval-ms : The interval at which to refresh the display.
+  If this property is not present, the default value is 1000.
+
+Examples:
+
+#include 
+
+seven-seg-disp {
+   compatible = "seven-seg-gpio-dev";
+   refresh-interval-ms = "1000";
+   clock-gpios = < 0 GPIO_ACTIVE_LOW>;
+   data-gpios = < 1 GPIO_ACTIVE_HIGH>;
+   clear-gpios = < 2 GPIO_ACTIVE_HIGH>;
+};
--
2.8.0.rc3.226.g39d4020



[PATCH linux v1 0/4] Seven segment display support

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
This patchset includes:

Documentation for the binding which provides an interface for adding clock,
data and clear signal GPIO lines to control seven segment display.

The platform device driver provides an API for displaying on two 7-segment
displays, and implements the required bit-banging. The hardware assumed is
74HC164 wired to two 7-segment displays.

The character device driver implements the user-space API for letting a user
write to two 7-segment displays including any conversion methods necessary
to map the user input to two 7-segment displays.

Adding clock, data and clear signal GPIO lines in the devicetree to control
seven segment display on zaius platform.

The platform driver matches on the device tree node; the platform driver also
initializes the character device.

Tested that the seven segment display works properly by writing to the
character device file on a EVB AST2500 board which also has 74HC164 wired
to two 7-segment displays.

Jaghathiswari Rankappagounder Natarajan (4):
  Documentation: dt-bindings: Document bindings for seven segment
display support
  drivers: misc: Character device driver for seven segment display
  drivers: misc: Platform driver for seven segment display support
  arm: dts: Add dt-binding to support seven segment display on zaius

 .../devicetree/bindings/misc/seven-seg-gpio.txt|  27 +++
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts |   8 +
 drivers/misc/Kconfig   |  16 ++
 drivers/misc/Makefile  |   2 +
 drivers/misc/seven_seg_disp.c  | 197 
 drivers/misc/seven_seg_disp.h  |  34 
 drivers/misc/seven_seg_gpio.c  | 206 +
 7 files changed, 490 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/seven-seg-gpio.txt
 create mode 100644 drivers/misc/seven_seg_disp.c
 create mode 100644 drivers/misc/seven_seg_disp.h
 create mode 100644 drivers/misc/seven_seg_gpio.c

--
2.8.0.rc3.226.g39d4020



[PATCH linux v1 0/4] Seven segment display support

2016-12-13 Thread Jaghathiswari Rankappagounder Natarajan
This patchset includes:

Documentation for the binding which provides an interface for adding clock,
data and clear signal GPIO lines to control seven segment display.

The platform device driver provides an API for displaying on two 7-segment
displays, and implements the required bit-banging. The hardware assumed is
74HC164 wired to two 7-segment displays.

The character device driver implements the user-space API for letting a user
write to two 7-segment displays including any conversion methods necessary
to map the user input to two 7-segment displays.

Adding clock, data and clear signal GPIO lines in the devicetree to control
seven segment display on zaius platform.

The platform driver matches on the device tree node; the platform driver also
initializes the character device.

Tested that the seven segment display works properly by writing to the
character device file on a EVB AST2500 board which also has 74HC164 wired
to two 7-segment displays.

Jaghathiswari Rankappagounder Natarajan (4):
  Documentation: dt-bindings: Document bindings for seven segment
display support
  drivers: misc: Character device driver for seven segment display
  drivers: misc: Platform driver for seven segment display support
  arm: dts: Add dt-binding to support seven segment display on zaius

 .../devicetree/bindings/misc/seven-seg-gpio.txt|  27 +++
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts |   8 +
 drivers/misc/Kconfig   |  16 ++
 drivers/misc/Makefile  |   2 +
 drivers/misc/seven_seg_disp.c  | 197 
 drivers/misc/seven_seg_disp.h  |  34 
 drivers/misc/seven_seg_gpio.c  | 206 +
 7 files changed, 490 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/seven-seg-gpio.txt
 create mode 100644 drivers/misc/seven_seg_disp.c
 create mode 100644 drivers/misc/seven_seg_disp.h
 create mode 100644 drivers/misc/seven_seg_gpio.c

--
2.8.0.rc3.226.g39d4020



RE: [PATCH 5/5] Documentation: fsl-quadspi: Add fsl, ls1012a-qspi compatible string

2016-12-13 Thread Yao Yuan
On Thu, Dec 14, 2016 at 05:23:02PM +0800, Rob Herring wrote:
> On Mon, Dec 12, 2016 at 8:47 PM, Yao Yuan  wrote:
> > On Thu, Dec 13, 2016 at 05:23:02PM +0800, Rob Herring wrote:
> >> On Thu, Dec 08, 2016 at 05:23:04PM +0800, Yuan Yao wrote:
> >> > From: Yuan Yao 
> >>
> >> Same problem in this subject too.
> >>
> >> >
> >> > new compatible string: "fsl,ls1012a-qspi".
> >> >
> >> > Signed-off-by: Yuan Yao 
> >> > ---
> >> >  Documentation/devicetree/bindings/mtd/fsl-quadspi.txt | 1 +
> >> >  1 file changed, 1 insertion(+)
> >>
> >> Acked-by: Rob Herring 
> >
> > Thanks for your review.
> > And do you have any suggestion for this subject?
> 
> The problem is you have a space in the compatible string: "fsl, ls1012a-qspi"
> rather than "fsl,ls1012a-qspi"
> 
> Also, I prefer "dt/bindings: " as the beginning of binding patch subjects.
> 

Ok, Get it.

Thanks for your comments.
I will send v2 soon.


RE: [PATCH 5/5] Documentation: fsl-quadspi: Add fsl, ls1012a-qspi compatible string

2016-12-13 Thread Yao Yuan
On Thu, Dec 14, 2016 at 05:23:02PM +0800, Rob Herring wrote:
> On Mon, Dec 12, 2016 at 8:47 PM, Yao Yuan  wrote:
> > On Thu, Dec 13, 2016 at 05:23:02PM +0800, Rob Herring wrote:
> >> On Thu, Dec 08, 2016 at 05:23:04PM +0800, Yuan Yao wrote:
> >> > From: Yuan Yao 
> >>
> >> Same problem in this subject too.
> >>
> >> >
> >> > new compatible string: "fsl,ls1012a-qspi".
> >> >
> >> > Signed-off-by: Yuan Yao 
> >> > ---
> >> >  Documentation/devicetree/bindings/mtd/fsl-quadspi.txt | 1 +
> >> >  1 file changed, 1 insertion(+)
> >>
> >> Acked-by: Rob Herring 
> >
> > Thanks for your review.
> > And do you have any suggestion for this subject?
> 
> The problem is you have a space in the compatible string: "fsl, ls1012a-qspi"
> rather than "fsl,ls1012a-qspi"
> 
> Also, I prefer "dt/bindings: " as the beginning of binding patch subjects.
> 

Ok, Get it.

Thanks for your comments.
I will send v2 soon.


Re: [PATCH v5 0/2] perf probe: add sdt probes arguments into the uprobe cmd string

2016-12-13 Thread Ingo Molnar

* Alexis Berlemont  wrote:

> Hi Masami,
> 
> Many thanks for your mail.
> 
> Here is another patch set which tries to fix the points you mentioned:
> 
> * Skip the arguments containing a constant ($123); 
> * Review the code in charge of the register renaming (search for '%'
>   and parse it);
> * Minor changes (print the argument in case of error, skipping, check
>   the sdt arg type index);
> 
> Many thanks,
> 
> Alexis.
> 
> Alexis Berlemont (2):
>   perf sdt: add scanning of sdt probles arguments
>   perf probe: add sdt probes arguments into the uprobe cmd string

I'd like to hijack this thread to report an SDT oddity - one of my boxen 
reports 
lots of SDT tracepoints in 'perf list':

  mem:[/len][:access]  [Hardware breakpoint]

  sdt_libc:lll_lock_wait_private [SDT event]
  sdt_libc:longjmp   [SDT event]
  sdt_libc:longjmp_target[SDT event]
  sdt_libc:memory_arena_new  [SDT event]
  sdt_libc:memory_arena_retry[SDT event]
  sdt_libc:memory_arena_reuse[SDT event]
  sdt_libc:memory_arena_reuse_free_list  [SDT event]
  sdt_libc:memory_arena_reuse_wait   [SDT event]
  sdt_libc:memory_calloc_retry   [SDT event]
  sdt_libc:memory_heap_free  [SDT event]
  ...

But none of them work:

  Error:  No permissions to read 
/sys/kernel/debug/tracing/events/sdt_libc/longjmp
  Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'

  ...

  Error:  File /sys/kernel/debug/tracing/events/sdt_libc/longjmp not found.
  Hint:   Perhaps this kernel misses some CONFIG_ setting to enable this 
feature?.

What kind of patches are required for SDT probes to work?

Thanks,

Ingo


Re: [PATCH v5 0/2] perf probe: add sdt probes arguments into the uprobe cmd string

2016-12-13 Thread Ingo Molnar

* Alexis Berlemont  wrote:

> Hi Masami,
> 
> Many thanks for your mail.
> 
> Here is another patch set which tries to fix the points you mentioned:
> 
> * Skip the arguments containing a constant ($123); 
> * Review the code in charge of the register renaming (search for '%'
>   and parse it);
> * Minor changes (print the argument in case of error, skipping, check
>   the sdt arg type index);
> 
> Many thanks,
> 
> Alexis.
> 
> Alexis Berlemont (2):
>   perf sdt: add scanning of sdt probles arguments
>   perf probe: add sdt probes arguments into the uprobe cmd string

I'd like to hijack this thread to report an SDT oddity - one of my boxen 
reports 
lots of SDT tracepoints in 'perf list':

  mem:[/len][:access]  [Hardware breakpoint]

  sdt_libc:lll_lock_wait_private [SDT event]
  sdt_libc:longjmp   [SDT event]
  sdt_libc:longjmp_target[SDT event]
  sdt_libc:memory_arena_new  [SDT event]
  sdt_libc:memory_arena_retry[SDT event]
  sdt_libc:memory_arena_reuse[SDT event]
  sdt_libc:memory_arena_reuse_free_list  [SDT event]
  sdt_libc:memory_arena_reuse_wait   [SDT event]
  sdt_libc:memory_calloc_retry   [SDT event]
  sdt_libc:memory_heap_free  [SDT event]
  ...

But none of them work:

  Error:  No permissions to read 
/sys/kernel/debug/tracing/events/sdt_libc/longjmp
  Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'

  ...

  Error:  File /sys/kernel/debug/tracing/events/sdt_libc/longjmp not found.
  Hint:   Perhaps this kernel misses some CONFIG_ setting to enable this 
feature?.

What kind of patches are required for SDT probes to work?

Thanks,

Ingo


Re: [PATCH v8 2/4] vcodec: mediatek: Add Mediatek JPEG Decoder Driver

2016-12-13 Thread Ricky Liang
Hi Rick,

Can you upload patchset v9 to address the issue? Thanks!

On Mon, Dec 12, 2016 at 5:07 PM, Rick Chang  wrote:
> Hi Ricky,
>
> Thanks for your feedback. We will fix the problem in another patch.
>
> On Mon, 2016-12-12 at 12:34 +0800, Ricky Liang wrote:
>> Hi Rick,
>>
>> On Wed, Nov 30, 2016 at 11:08 AM, Rick Chang  wrote:
>> > Add v4l2 driver for Mediatek JPEG Decoder
>> >
>> > Signed-off-by: Rick Chang 
>> > Signed-off-by: Minghsiu Tsai 
>>
>> 
>>
>> > +static bool mtk_jpeg_check_resolution_change(struct mtk_jpeg_ctx *ctx,
>> > +struct mtk_jpeg_dec_param 
>> > *param)
>> > +{
>> > +   struct mtk_jpeg_dev *jpeg = ctx->jpeg;
>> > +   struct mtk_jpeg_q_data *q_data;
>> > +
>> > +   q_data = >out_q;
>> > +   if (q_data->w != param->pic_w || q_data->h != param->pic_h) {
>> > +   v4l2_dbg(1, debug, >v4l2_dev, "Picture size 
>> > change\n");
>> > +   return true;
>> > +   }
>> > +
>> > +   q_data = >cap_q;
>> > +   if (q_data->fmt != mtk_jpeg_find_format(ctx, param->dst_fourcc,
>> > +   
>> > MTK_JPEG_FMT_TYPE_CAPTURE)) {
>> > +   v4l2_dbg(1, debug, >v4l2_dev, "format change\n");
>> > +   return true;
>> > +   }
>> > +   return false;
>>
>> 
>>
>> > +static void mtk_jpeg_device_run(void *priv)
>> > +{
>> > +   struct mtk_jpeg_ctx *ctx = priv;
>> > +   struct mtk_jpeg_dev *jpeg = ctx->jpeg;
>> > +   struct vb2_buffer *src_buf, *dst_buf;
>> > +   enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
>> > +   unsigned long flags;
>> > +   struct mtk_jpeg_src_buf *jpeg_src_buf;
>> > +   struct mtk_jpeg_bs bs;
>> > +   struct mtk_jpeg_fb fb;
>> > +   int i;
>> > +
>> > +   src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
>> > +   dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
>> > +   jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf);
>> > +
>> > +   if (jpeg_src_buf->flags & MTK_JPEG_BUF_FLAGS_LAST_FRAME) {
>> > +   for (i = 0; i < dst_buf->num_planes; i++)
>> > +   vb2_set_plane_payload(dst_buf, i, 0);
>> > +   buf_state = VB2_BUF_STATE_DONE;
>> > +   goto dec_end;
>> > +   }
>> > +
>> > +   if (mtk_jpeg_check_resolution_change(ctx, 
>> > _src_buf->dec_param)) {
>> > +   mtk_jpeg_queue_src_chg_event(ctx);
>> > +   ctx->state = MTK_JPEG_SOURCE_CHANGE;
>> > +   v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
>> > +   return;
>> > +   }
>>
>> This only detects source change if multiple OUPUT buffers are queued.
>> It does not catch the source change in the following scenario:
>>
>> - OUPUT buffers for jpeg1 enqueued
>> - OUTPUT queue STREAMON
>> - userspace creates CAPTURE buffers
>> - CAPTURE buffers enqueued
>> - CAPTURE queue STREAMON
>> - decode
>> - OUTPUT queue STREAMOFF
>> - userspace recreates OUTPUT buffers for jpeg2
>> - OUTPUT buffers for jpeg2 enqueued
>> - OUTPUT queue STREAMON
>>
>> In the above sequence if jpeg2's decoded size is larger than jpeg1 the
>> function fails to detect that the existing CAPTURE buffers are not big
>> enough to hold the decoded data.
>>
>> A possible fix is to pass *dst_buf to
>> mtk_jpeg_check_resolution_change(), and check in the function that all
>> the dst_buf planes are large enough to hold the decoded data.
>>
>> > +
>> > +   mtk_jpeg_set_dec_src(ctx, src_buf, );
>> > +   if (mtk_jpeg_set_dec_dst(ctx, _src_buf->dec_param, dst_buf, 
>> > ))
>> > +   goto dec_end;
>> > +
>> > +   spin_lock_irqsave(>hw_lock, flags);
>> > +   mtk_jpeg_dec_reset(jpeg->dec_reg_base);
>> > +   mtk_jpeg_dec_set_config(jpeg->dec_reg_base,
>> > +   _src_buf->dec_param, , );
>> > +
>> > +   mtk_jpeg_dec_start(jpeg->dec_reg_base);
>> > +   spin_unlock_irqrestore(>hw_lock, flags);
>> > +   return;
>> > +
>> > +dec_end:
>> > +   v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
>> > +   v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
>> > +   v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state);
>> > +   v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state);
>> > +   v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
>> > +}
>>
>> 
>
>


Re: [PATCH v8 2/4] vcodec: mediatek: Add Mediatek JPEG Decoder Driver

2016-12-13 Thread Ricky Liang
Hi Rick,

Can you upload patchset v9 to address the issue? Thanks!

On Mon, Dec 12, 2016 at 5:07 PM, Rick Chang  wrote:
> Hi Ricky,
>
> Thanks for your feedback. We will fix the problem in another patch.
>
> On Mon, 2016-12-12 at 12:34 +0800, Ricky Liang wrote:
>> Hi Rick,
>>
>> On Wed, Nov 30, 2016 at 11:08 AM, Rick Chang  wrote:
>> > Add v4l2 driver for Mediatek JPEG Decoder
>> >
>> > Signed-off-by: Rick Chang 
>> > Signed-off-by: Minghsiu Tsai 
>>
>> 
>>
>> > +static bool mtk_jpeg_check_resolution_change(struct mtk_jpeg_ctx *ctx,
>> > +struct mtk_jpeg_dec_param 
>> > *param)
>> > +{
>> > +   struct mtk_jpeg_dev *jpeg = ctx->jpeg;
>> > +   struct mtk_jpeg_q_data *q_data;
>> > +
>> > +   q_data = >out_q;
>> > +   if (q_data->w != param->pic_w || q_data->h != param->pic_h) {
>> > +   v4l2_dbg(1, debug, >v4l2_dev, "Picture size 
>> > change\n");
>> > +   return true;
>> > +   }
>> > +
>> > +   q_data = >cap_q;
>> > +   if (q_data->fmt != mtk_jpeg_find_format(ctx, param->dst_fourcc,
>> > +   
>> > MTK_JPEG_FMT_TYPE_CAPTURE)) {
>> > +   v4l2_dbg(1, debug, >v4l2_dev, "format change\n");
>> > +   return true;
>> > +   }
>> > +   return false;
>>
>> 
>>
>> > +static void mtk_jpeg_device_run(void *priv)
>> > +{
>> > +   struct mtk_jpeg_ctx *ctx = priv;
>> > +   struct mtk_jpeg_dev *jpeg = ctx->jpeg;
>> > +   struct vb2_buffer *src_buf, *dst_buf;
>> > +   enum vb2_buffer_state buf_state = VB2_BUF_STATE_ERROR;
>> > +   unsigned long flags;
>> > +   struct mtk_jpeg_src_buf *jpeg_src_buf;
>> > +   struct mtk_jpeg_bs bs;
>> > +   struct mtk_jpeg_fb fb;
>> > +   int i;
>> > +
>> > +   src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
>> > +   dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
>> > +   jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(src_buf);
>> > +
>> > +   if (jpeg_src_buf->flags & MTK_JPEG_BUF_FLAGS_LAST_FRAME) {
>> > +   for (i = 0; i < dst_buf->num_planes; i++)
>> > +   vb2_set_plane_payload(dst_buf, i, 0);
>> > +   buf_state = VB2_BUF_STATE_DONE;
>> > +   goto dec_end;
>> > +   }
>> > +
>> > +   if (mtk_jpeg_check_resolution_change(ctx, 
>> > _src_buf->dec_param)) {
>> > +   mtk_jpeg_queue_src_chg_event(ctx);
>> > +   ctx->state = MTK_JPEG_SOURCE_CHANGE;
>> > +   v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
>> > +   return;
>> > +   }
>>
>> This only detects source change if multiple OUPUT buffers are queued.
>> It does not catch the source change in the following scenario:
>>
>> - OUPUT buffers for jpeg1 enqueued
>> - OUTPUT queue STREAMON
>> - userspace creates CAPTURE buffers
>> - CAPTURE buffers enqueued
>> - CAPTURE queue STREAMON
>> - decode
>> - OUTPUT queue STREAMOFF
>> - userspace recreates OUTPUT buffers for jpeg2
>> - OUTPUT buffers for jpeg2 enqueued
>> - OUTPUT queue STREAMON
>>
>> In the above sequence if jpeg2's decoded size is larger than jpeg1 the
>> function fails to detect that the existing CAPTURE buffers are not big
>> enough to hold the decoded data.
>>
>> A possible fix is to pass *dst_buf to
>> mtk_jpeg_check_resolution_change(), and check in the function that all
>> the dst_buf planes are large enough to hold the decoded data.
>>
>> > +
>> > +   mtk_jpeg_set_dec_src(ctx, src_buf, );
>> > +   if (mtk_jpeg_set_dec_dst(ctx, _src_buf->dec_param, dst_buf, 
>> > ))
>> > +   goto dec_end;
>> > +
>> > +   spin_lock_irqsave(>hw_lock, flags);
>> > +   mtk_jpeg_dec_reset(jpeg->dec_reg_base);
>> > +   mtk_jpeg_dec_set_config(jpeg->dec_reg_base,
>> > +   _src_buf->dec_param, , );
>> > +
>> > +   mtk_jpeg_dec_start(jpeg->dec_reg_base);
>> > +   spin_unlock_irqrestore(>hw_lock, flags);
>> > +   return;
>> > +
>> > +dec_end:
>> > +   v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
>> > +   v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
>> > +   v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf), buf_state);
>> > +   v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), buf_state);
>> > +   v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx);
>> > +}
>>
>> 
>
>


Re: Revised keyrings(7) man page for review

2016-12-13 Thread Michael Kerrisk (man-pages)
On 12/13/2016 03:20 PM, David Howells wrote:
> Michael Kerrisk (man-pages)  wrote:
> 
>>   The payload data may  be  stored  in  a  tmpfs  filesystem,
>>   rather  than in kernel memory, if the data size exceeds the
>>   overhead of storing the data in the  filesystem.   (Storing
>>   the  data in a filesystem requires filesystem structures to
>>   be allocated in the kernel.  The size of  these  structures
>>   determines the size threshold above which the tmpfs storage
>>   method is used.)  Since Linux  4.8,  the  payload  data  is
>>   encrypted when stored in tmpfs, to prevent it being written
>>   unencrypted into swap space.
> 
> "... thereby preventing it from being written unencrypted into the swapspace"?

Fixed.

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/


Re: Revised keyrings(7) man page for review

2016-12-13 Thread Michael Kerrisk (man-pages)
On 12/13/2016 03:20 PM, David Howells wrote:
> Michael Kerrisk (man-pages)  wrote:
> 
>>   The payload data may  be  stored  in  a  tmpfs  filesystem,
>>   rather  than in kernel memory, if the data size exceeds the
>>   overhead of storing the data in the  filesystem.   (Storing
>>   the  data in a filesystem requires filesystem structures to
>>   be allocated in the kernel.  The size of  these  structures
>>   determines the size threshold above which the tmpfs storage
>>   method is used.)  Since Linux  4.8,  the  payload  data  is
>>   encrypted when stored in tmpfs, to prevent it being written
>>   unencrypted into swap space.
> 
> "... thereby preventing it from being written unencrypted into the swapspace"?

Fixed.

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/


RE: [PATCH v3 9/9] NTB: Add ntb.h comments

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  include/linux/ntb.h | 19 ---
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index 6d46179..dab0a1b 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -326,12 +326,17 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>  {
>   /* commented callbacks are not required: */
>   return
> + /* Port operations are required for multiport devices */
>   !ops->peer_port_count == !ops->port_number  &&
>   !ops->peer_port_number == !ops->port_number &&
>   !ops->peer_port_idx == !ops->port_number&&
> +
> + /* Link operations are required */
>   ops->link_is_up &&
>   ops->link_enable&&
>   ops->link_disable   &&
> +
> + /* One or both MW interfaces should be developed */
>   ops->mw_count   &&
>   ops->mw_get_align   &&
>   (ops->mw_set_trans  ||
> @@ -341,12 +346,11 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>   ops->peer_mw_get_addr   &&
>   /* ops->peer_mw_clear_trans && */
> 
> + /* Doorbell operations are mostly required */
>   /* ops->db_is_unsafe&& */
>   ops->db_valid_mask  &&
> -
>   /* both set, or both unset */
> - (!ops->db_vector_count == !ops->db_vector_mask) &&
> -
> + (!ops->db_vector_count == !ops->db_vector_mask) &&
>   ops->db_read&&
>   /* ops->db_set  && */
>   ops->db_clear   &&
> @@ -360,6 +364,8 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* ops->peer_db_read_mask   && */
>   /* ops->peer_db_set_mask&& */
>   /* ops->peer_db_clear_mask  && */
> +
> + /* Scrachpads interface is optional */
>   /* !ops->spad_is_unsafe == !ops->spad_count && */
>   !ops->spad_read == !ops->spad_count &&
>   !ops->spad_write == !ops->spad_count&&
> @@ -367,6 +373,7 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* !ops->peer_spad_read == !ops->spad_count && */
>   !ops->peer_spad_write == !ops->spad_count   &&
> 
> + /* Messaging interface is optional */
>   !ops->msg_inbits == !ops->msg_count &&
>   !ops->msg_outbits == !ops->msg_count&&
>   !ops->msg_read_sts == !ops->msg_count   &&
> @@ -387,13 +394,12 @@ struct ntb_client {
>   struct device_driverdrv;
>   const struct ntb_client_ops ops;
>  };
> -
>  #define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
> 
>  /**
>   * struct ntb_device - ntb device
>   * @dev: Linux device object.
> - * @pdev:Pci device entry of the ntb.
> + * @pdev:PCI device entry of the ntb.
>   * @topo:Detected topology of the ntb.
>   * @ops: See _dev_ops.
>   * @ctx: See _ctx_ops.
> @@ -414,7 +420,6 @@ struct ntb_dev {
>   /* block unregister until device is fully released */
>   struct completion   released;
>  };
> -
>  #define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
> 
>  /**
> @@ -511,7 +516,7 @@ void ntb_link_event(struct ntb_dev *ntb);
>   * multiple interrupt vectors for doorbells, the vector number indicates 
> which
>   * vector received the interrupt.  The vector number is relative to the first
>   * vector used for doorbells, starting at zero, and must be less than
> - ** ntb_db_vector_count().  The driver may call ntb_db_read() to check which
> + * ntb_db_vector_count().  The driver may call ntb_db_read() to check which
>   * doorbell bits need service, and ntb_db_vector_mask() to determine which of
>   * those bits are associated with the vector number.
>   */
> --
> 2.6.6




RE: [PATCH v3 9/9] NTB: Add ntb.h comments

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  include/linux/ntb.h | 19 ---
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index 6d46179..dab0a1b 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -326,12 +326,17 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>  {
>   /* commented callbacks are not required: */
>   return
> + /* Port operations are required for multiport devices */
>   !ops->peer_port_count == !ops->port_number  &&
>   !ops->peer_port_number == !ops->port_number &&
>   !ops->peer_port_idx == !ops->port_number&&
> +
> + /* Link operations are required */
>   ops->link_is_up &&
>   ops->link_enable&&
>   ops->link_disable   &&
> +
> + /* One or both MW interfaces should be developed */
>   ops->mw_count   &&
>   ops->mw_get_align   &&
>   (ops->mw_set_trans  ||
> @@ -341,12 +346,11 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>   ops->peer_mw_get_addr   &&
>   /* ops->peer_mw_clear_trans && */
> 
> + /* Doorbell operations are mostly required */
>   /* ops->db_is_unsafe&& */
>   ops->db_valid_mask  &&
> -
>   /* both set, or both unset */
> - (!ops->db_vector_count == !ops->db_vector_mask) &&
> -
> + (!ops->db_vector_count == !ops->db_vector_mask) &&
>   ops->db_read&&
>   /* ops->db_set  && */
>   ops->db_clear   &&
> @@ -360,6 +364,8 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* ops->peer_db_read_mask   && */
>   /* ops->peer_db_set_mask&& */
>   /* ops->peer_db_clear_mask  && */
> +
> + /* Scrachpads interface is optional */
>   /* !ops->spad_is_unsafe == !ops->spad_count && */
>   !ops->spad_read == !ops->spad_count &&
>   !ops->spad_write == !ops->spad_count&&
> @@ -367,6 +373,7 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* !ops->peer_spad_read == !ops->spad_count && */
>   !ops->peer_spad_write == !ops->spad_count   &&
> 
> + /* Messaging interface is optional */
>   !ops->msg_inbits == !ops->msg_count &&
>   !ops->msg_outbits == !ops->msg_count&&
>   !ops->msg_read_sts == !ops->msg_count   &&
> @@ -387,13 +394,12 @@ struct ntb_client {
>   struct device_driverdrv;
>   const struct ntb_client_ops ops;
>  };
> -
>  #define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
> 
>  /**
>   * struct ntb_device - ntb device
>   * @dev: Linux device object.
> - * @pdev:Pci device entry of the ntb.
> + * @pdev:PCI device entry of the ntb.
>   * @topo:Detected topology of the ntb.
>   * @ops: See _dev_ops.
>   * @ctx: See _ctx_ops.
> @@ -414,7 +420,6 @@ struct ntb_dev {
>   /* block unregister until device is fully released */
>   struct completion   released;
>  };
> -
>  #define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
> 
>  /**
> @@ -511,7 +516,7 @@ void ntb_link_event(struct ntb_dev *ntb);
>   * multiple interrupt vectors for doorbells, the vector number indicates 
> which
>   * vector received the interrupt.  The vector number is relative to the first
>   * vector used for doorbells, starting at zero, and must be less than
> - ** ntb_db_vector_count().  The driver may call ntb_db_read() to check which
> + * ntb_db_vector_count().  The driver may call ntb_db_read() to check which
>   * doorbell bits need service, and ntb_db_vector_mask() to determine which of
>   * those bits are associated with the vector number.
>   */
> --
> 2.6.6




[PATCH V1] i2c: xgene: Fix missing code of DTB support

2016-12-13 Thread Tin Huynh
In DTB case, i2c-core doesn't create slave device which is installed
on i2c-xgene bus because of missing code in this driver.
This patch fixes this issue.

Signed-off-by: Tin Huynh 
---
 drivers/i2c/busses/i2c-xgene-slimpro.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c 
b/drivers/i2c/busses/i2c-xgene-slimpro.c
index 263685c..00d1632 100644
--- a/drivers/i2c/busses/i2c-xgene-slimpro.c
+++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
@@ -415,6 +415,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device 
*pdev)
adapter->algo = _slimpro_i2c_algorithm;
adapter->class = I2C_CLASS_HWMON;
adapter->dev.parent = >dev;
+   adapter->dev.of_node = pdev->dev.of_node;
i2c_set_adapdata(adapter, ctx);
rc = i2c_add_adapter(adapter);
if (rc) {
-- 
1.7.1



[PATCH V1] i2c: xgene: Fix missing code of DTB support

2016-12-13 Thread Tin Huynh
In DTB case, i2c-core doesn't create slave device which is installed
on i2c-xgene bus because of missing code in this driver.
This patch fixes this issue.

Signed-off-by: Tin Huynh 
---
 drivers/i2c/busses/i2c-xgene-slimpro.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c 
b/drivers/i2c/busses/i2c-xgene-slimpro.c
index 263685c..00d1632 100644
--- a/drivers/i2c/busses/i2c-xgene-slimpro.c
+++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
@@ -415,6 +415,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device 
*pdev)
adapter->algo = _slimpro_i2c_algorithm;
adapter->class = I2C_CLASS_HWMON;
adapter->dev.parent = >dev;
+   adapter->dev.of_node = pdev->dev.of_node;
i2c_set_adapdata(adapter, ctx);
rc = i2c_add_adapter(adapter);
if (rc) {
-- 
1.7.1



[PATCH v3 9/9] NTB: Add ntb.h comments

2016-12-13 Thread Serge Semin
Signed-off-by: Serge Semin 
---
 include/linux/ntb.h | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index 6d46179..dab0a1b 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -326,12 +326,17 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
 {
/* commented callbacks are not required: */
return
+   /* Port operations are required for multiport devices */
!ops->peer_port_count == !ops->port_number  &&
!ops->peer_port_number == !ops->port_number &&
!ops->peer_port_idx == !ops->port_number&&
+
+   /* Link operations are required */
ops->link_is_up &&
ops->link_enable&&
ops->link_disable   &&
+
+   /* One or both MW interfaces should be developed */
ops->mw_count   &&
ops->mw_get_align   &&
(ops->mw_set_trans  ||
@@ -341,12 +346,11 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
ops->peer_mw_get_addr   &&
/* ops->peer_mw_clear_trans && */
 
+   /* Doorbell operations are mostly required */
/* ops->db_is_unsafe&& */
ops->db_valid_mask  &&
-
/* both set, or both unset */
-   (!ops->db_vector_count == !ops->db_vector_mask) &&
-
+   (!ops->db_vector_count == !ops->db_vector_mask) &&
ops->db_read&&
/* ops->db_set  && */
ops->db_clear   &&
@@ -360,6 +364,8 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
/* ops->peer_db_read_mask   && */
/* ops->peer_db_set_mask&& */
/* ops->peer_db_clear_mask  && */
+
+   /* Scrachpads interface is optional */
/* !ops->spad_is_unsafe == !ops->spad_count && */
!ops->spad_read == !ops->spad_count &&
!ops->spad_write == !ops->spad_count&&
@@ -367,6 +373,7 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
/* !ops->peer_spad_read == !ops->spad_count && */
!ops->peer_spad_write == !ops->spad_count   &&
 
+   /* Messaging interface is optional */
!ops->msg_inbits == !ops->msg_count &&
!ops->msg_outbits == !ops->msg_count&&
!ops->msg_read_sts == !ops->msg_count   &&
@@ -387,13 +394,12 @@ struct ntb_client {
struct device_driverdrv;
const struct ntb_client_ops ops;
 };
-
 #define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
 
 /**
  * struct ntb_device - ntb device
  * @dev:   Linux device object.
- * @pdev:  Pci device entry of the ntb.
+ * @pdev:  PCI device entry of the ntb.
  * @topo:  Detected topology of the ntb.
  * @ops:   See _dev_ops.
  * @ctx:   See _ctx_ops.
@@ -414,7 +420,6 @@ struct ntb_dev {
/* block unregister until device is fully released */
struct completion   released;
 };
-
 #define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
 
 /**
@@ -511,7 +516,7 @@ void ntb_link_event(struct ntb_dev *ntb);
  * multiple interrupt vectors for doorbells, the vector number indicates which
  * vector received the interrupt.  The vector number is relative to the first
  * vector used for doorbells, starting at zero, and must be less than
- ** ntb_db_vector_count().  The driver may call ntb_db_read() to check which
+ * ntb_db_vector_count().  The driver may call ntb_db_read() to check which
  * doorbell bits need service, and ntb_db_vector_mask() to determine which of
  * those bits are associated with the vector number.
  */
-- 
2.6.6



[PATCH v3 9/9] NTB: Add ntb.h comments

2016-12-13 Thread Serge Semin
Signed-off-by: Serge Semin 
---
 include/linux/ntb.h | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index 6d46179..dab0a1b 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -326,12 +326,17 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
 {
/* commented callbacks are not required: */
return
+   /* Port operations are required for multiport devices */
!ops->peer_port_count == !ops->port_number  &&
!ops->peer_port_number == !ops->port_number &&
!ops->peer_port_idx == !ops->port_number&&
+
+   /* Link operations are required */
ops->link_is_up &&
ops->link_enable&&
ops->link_disable   &&
+
+   /* One or both MW interfaces should be developed */
ops->mw_count   &&
ops->mw_get_align   &&
(ops->mw_set_trans  ||
@@ -341,12 +346,11 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
ops->peer_mw_get_addr   &&
/* ops->peer_mw_clear_trans && */
 
+   /* Doorbell operations are mostly required */
/* ops->db_is_unsafe&& */
ops->db_valid_mask  &&
-
/* both set, or both unset */
-   (!ops->db_vector_count == !ops->db_vector_mask) &&
-
+   (!ops->db_vector_count == !ops->db_vector_mask) &&
ops->db_read&&
/* ops->db_set  && */
ops->db_clear   &&
@@ -360,6 +364,8 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
/* ops->peer_db_read_mask   && */
/* ops->peer_db_set_mask&& */
/* ops->peer_db_clear_mask  && */
+
+   /* Scrachpads interface is optional */
/* !ops->spad_is_unsafe == !ops->spad_count && */
!ops->spad_read == !ops->spad_count &&
!ops->spad_write == !ops->spad_count&&
@@ -367,6 +373,7 @@ static inline int ntb_dev_ops_is_valid(const struct 
ntb_dev_ops *ops)
/* !ops->peer_spad_read == !ops->spad_count && */
!ops->peer_spad_write == !ops->spad_count   &&
 
+   /* Messaging interface is optional */
!ops->msg_inbits == !ops->msg_count &&
!ops->msg_outbits == !ops->msg_count&&
!ops->msg_read_sts == !ops->msg_count   &&
@@ -387,13 +394,12 @@ struct ntb_client {
struct device_driverdrv;
const struct ntb_client_ops ops;
 };
-
 #define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
 
 /**
  * struct ntb_device - ntb device
  * @dev:   Linux device object.
- * @pdev:  Pci device entry of the ntb.
+ * @pdev:  PCI device entry of the ntb.
  * @topo:  Detected topology of the ntb.
  * @ops:   See _dev_ops.
  * @ctx:   See _ctx_ops.
@@ -414,7 +420,6 @@ struct ntb_dev {
/* block unregister until device is fully released */
struct completion   released;
 };
-
 #define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
 
 /**
@@ -511,7 +516,7 @@ void ntb_link_event(struct ntb_dev *ntb);
  * multiple interrupt vectors for doorbells, the vector number indicates which
  * vector received the interrupt.  The vector number is relative to the first
  * vector used for doorbells, starting at zero, and must be less than
- ** ntb_db_vector_count().  The driver may call ntb_db_read() to check which
+ * ntb_db_vector_count().  The driver may call ntb_db_read() to check which
  * doorbell bits need service, and ntb_db_vector_mask() to determine which of
  * those bits are associated with the vector number.
  */
-- 
2.6.6



[PATCH v3] net: macb: Added PCI wrapper for Platform Driver.

2016-12-13 Thread Bartosz Folta
There are hardware PCI implementations of Cadence GEM network
controller. This patch will allow to use such hardware with reuse of
existing Platform Driver.

Signed-off-by: Bartosz Folta 
---
Changed in v3:
Fixed dependencies in Kconfig.
---
Changed in v2:
Respin to net-next. Changed patch formatting.
---
 drivers/net/ethernet/cadence/Kconfig|   9 ++
 drivers/net/ethernet/cadence/Makefile   |   1 +
 drivers/net/ethernet/cadence/macb.c |  31 +--
 drivers/net/ethernet/cadence/macb_pci.c | 153 
 include/linux/platform_data/macb.h  |   6 ++
 5 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/cadence/macb_pci.c

diff --git a/drivers/net/ethernet/cadence/Kconfig 
b/drivers/net/ethernet/cadence/Kconfig
index f0bcb15..608bea1 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -31,4 +31,13 @@ config MACB
  To compile this driver as a module, choose M here: the module
  will be called macb.
 
+config MACB_PCI
+   tristate "Cadence PCI MACB/GEM support"
+   depends on MACB && PCI && COMMON_CLK
+   ---help---
+ This is PCI wrapper for MACB driver.
+
+ To compile this driver as a module, choose M here: the module
+ will be called macb_pci.
+
 endif # NET_CADENCE
diff --git a/drivers/net/ethernet/cadence/Makefile 
b/drivers/net/ethernet/cadence/Makefile
index 91f79b1..4ba7559 100644
--- a/drivers/net/ethernet/cadence/Makefile
+++ b/drivers/net/ethernet/cadence/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_MACB) += macb.o
+obj-$(CONFIG_MACB_PCI) += macb_pci.o
diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 538544a..c0fb80a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -404,6 +404,8 @@ static int macb_mii_probe(struct net_device *dev)
phy_irq = gpio_to_irq(pdata->phy_irq_pin);
phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq;
}
+   } else {
+   phydev->irq = PHY_POLL;
}
 
/* attach the mac to the phy */
@@ -482,6 +484,9 @@ static int macb_mii_init(struct macb *bp)
goto err_out_unregister_bus;
}
} else {
+   for (i = 0; i < PHY_MAX_ADDR; i++)
+   bp->mii_bus->irq[i] = PHY_POLL;
+
if (pdata)
bp->mii_bus->phy_mask = pdata->phy_mask;
 
@@ -2523,16 +2528,24 @@ static int macb_clk_init(struct platform_device *pdev, 
struct clk **pclk,
 struct clk **hclk, struct clk **tx_clk,
 struct clk **rx_clk)
 {
+   struct macb_platform_data *pdata;
int err;
 
-   *pclk = devm_clk_get(>dev, "pclk");
+   pdata = dev_get_platdata(>dev);
+   if (pdata) {
+   *pclk = pdata->pclk;
+   *hclk = pdata->hclk;
+   } else {
+   *pclk = devm_clk_get(>dev, "pclk");
+   *hclk = devm_clk_get(>dev, "hclk");
+   }
+
if (IS_ERR(*pclk)) {
err = PTR_ERR(*pclk);
dev_err(>dev, "failed to get macb_clk (%u)\n", err);
return err;
}
 
-   *hclk = devm_clk_get(>dev, "hclk");
if (IS_ERR(*hclk)) {
err = PTR_ERR(*hclk);
dev_err(>dev, "failed to get hclk (%u)\n", err);
@@ -3107,15 +3120,23 @@ static int at91ether_init(struct platform_device *pdev)
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
 #endif /* CONFIG_OF */
 
+static const struct macb_config default_gem_config = {
+   .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO,
+   .dma_burst_length = 16,
+   .clk_init = macb_clk_init,
+   .init = macb_init,
+   .jumbo_max_len = 10240,
+};
+
 static int macb_probe(struct platform_device *pdev)
 {
+   const struct macb_config *macb_config = _gem_config;
int (*clk_init)(struct platform_device *, struct clk **,
struct clk **, struct clk **,  struct clk **)
- = macb_clk_init;
-   int (*init)(struct platform_device *) = macb_init;
+ = macb_config->clk_init;
+   int (*init)(struct platform_device *) = macb_config->init;
struct device_node *np = pdev->dev.of_node;
struct device_node *phy_node;
-   const struct macb_config *macb_config = NULL;
struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
unsigned int queue_mask, num_queues;
struct macb_platform_data *pdata;
diff --git a/drivers/net/ethernet/cadence/macb_pci.c 
b/drivers/net/ethernet/cadence/macb_pci.c
new file mode 100644
index 000..92be2cd
--- /dev/null
+++ b/drivers/net/ethernet/cadence/macb_pci.c
@@ -0,0 +1,153 @@
+/**
+ * macb_pci.c - Cadence GEM PCI wrapper.
+ *
+ 

[PATCH v3] net: macb: Added PCI wrapper for Platform Driver.

2016-12-13 Thread Bartosz Folta
There are hardware PCI implementations of Cadence GEM network
controller. This patch will allow to use such hardware with reuse of
existing Platform Driver.

Signed-off-by: Bartosz Folta 
---
Changed in v3:
Fixed dependencies in Kconfig.
---
Changed in v2:
Respin to net-next. Changed patch formatting.
---
 drivers/net/ethernet/cadence/Kconfig|   9 ++
 drivers/net/ethernet/cadence/Makefile   |   1 +
 drivers/net/ethernet/cadence/macb.c |  31 +--
 drivers/net/ethernet/cadence/macb_pci.c | 153 
 include/linux/platform_data/macb.h  |   6 ++
 5 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/cadence/macb_pci.c

diff --git a/drivers/net/ethernet/cadence/Kconfig 
b/drivers/net/ethernet/cadence/Kconfig
index f0bcb15..608bea1 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -31,4 +31,13 @@ config MACB
  To compile this driver as a module, choose M here: the module
  will be called macb.
 
+config MACB_PCI
+   tristate "Cadence PCI MACB/GEM support"
+   depends on MACB && PCI && COMMON_CLK
+   ---help---
+ This is PCI wrapper for MACB driver.
+
+ To compile this driver as a module, choose M here: the module
+ will be called macb_pci.
+
 endif # NET_CADENCE
diff --git a/drivers/net/ethernet/cadence/Makefile 
b/drivers/net/ethernet/cadence/Makefile
index 91f79b1..4ba7559 100644
--- a/drivers/net/ethernet/cadence/Makefile
+++ b/drivers/net/ethernet/cadence/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_MACB) += macb.o
+obj-$(CONFIG_MACB_PCI) += macb_pci.o
diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 538544a..c0fb80a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -404,6 +404,8 @@ static int macb_mii_probe(struct net_device *dev)
phy_irq = gpio_to_irq(pdata->phy_irq_pin);
phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq;
}
+   } else {
+   phydev->irq = PHY_POLL;
}
 
/* attach the mac to the phy */
@@ -482,6 +484,9 @@ static int macb_mii_init(struct macb *bp)
goto err_out_unregister_bus;
}
} else {
+   for (i = 0; i < PHY_MAX_ADDR; i++)
+   bp->mii_bus->irq[i] = PHY_POLL;
+
if (pdata)
bp->mii_bus->phy_mask = pdata->phy_mask;
 
@@ -2523,16 +2528,24 @@ static int macb_clk_init(struct platform_device *pdev, 
struct clk **pclk,
 struct clk **hclk, struct clk **tx_clk,
 struct clk **rx_clk)
 {
+   struct macb_platform_data *pdata;
int err;
 
-   *pclk = devm_clk_get(>dev, "pclk");
+   pdata = dev_get_platdata(>dev);
+   if (pdata) {
+   *pclk = pdata->pclk;
+   *hclk = pdata->hclk;
+   } else {
+   *pclk = devm_clk_get(>dev, "pclk");
+   *hclk = devm_clk_get(>dev, "hclk");
+   }
+
if (IS_ERR(*pclk)) {
err = PTR_ERR(*pclk);
dev_err(>dev, "failed to get macb_clk (%u)\n", err);
return err;
}
 
-   *hclk = devm_clk_get(>dev, "hclk");
if (IS_ERR(*hclk)) {
err = PTR_ERR(*hclk);
dev_err(>dev, "failed to get hclk (%u)\n", err);
@@ -3107,15 +3120,23 @@ static int at91ether_init(struct platform_device *pdev)
 MODULE_DEVICE_TABLE(of, macb_dt_ids);
 #endif /* CONFIG_OF */
 
+static const struct macb_config default_gem_config = {
+   .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO,
+   .dma_burst_length = 16,
+   .clk_init = macb_clk_init,
+   .init = macb_init,
+   .jumbo_max_len = 10240,
+};
+
 static int macb_probe(struct platform_device *pdev)
 {
+   const struct macb_config *macb_config = _gem_config;
int (*clk_init)(struct platform_device *, struct clk **,
struct clk **, struct clk **,  struct clk **)
- = macb_clk_init;
-   int (*init)(struct platform_device *) = macb_init;
+ = macb_config->clk_init;
+   int (*init)(struct platform_device *) = macb_config->init;
struct device_node *np = pdev->dev.of_node;
struct device_node *phy_node;
-   const struct macb_config *macb_config = NULL;
struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
unsigned int queue_mask, num_queues;
struct macb_platform_data *pdata;
diff --git a/drivers/net/ethernet/cadence/macb_pci.c 
b/drivers/net/ethernet/cadence/macb_pci.c
new file mode 100644
index 000..92be2cd
--- /dev/null
+++ b/drivers/net/ethernet/cadence/macb_pci.c
@@ -0,0 +1,153 @@
+/**
+ * macb_pci.c - Cadence GEM PCI wrapper.
+ *
+ * Copyright (C) 

RE: [PATCH v3 9/9] NTB: Add ntb.h comments

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Signed-off-by: Serge Semin 
> ---
>  include/linux/ntb.h | 19 ---
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index 6d46179..dab0a1b 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -326,12 +326,17 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>  {
>   /* commented callbacks are not required: */
>   return
> + /* Port operations are required */

... for multiport devices.

>   !ops->peer_port_count == !ops->port_number  &&
>   !ops->peer_port_number == !ops->port_number &&
>   !ops->peer_port_idx == !ops->port_number&&
> +
> + /* Link operations are requiered */
>   ops->link_is_up &&
>   ops->link_enable&&
>   ops->link_disable   &&
> +
> + /* One or both MW interfaces should be developed */
>   ops->mw_count   &&
>   ops->mw_get_align   &&
>   (ops->mw_set_trans  ||
> @@ -341,12 +346,11 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>   ops->peer_mw_get_addr   &&
>   /* ops->peer_mw_clear_trans && */
> 
> + /* Doorbell operations are mostly required */
>   /* ops->db_is_unsafe&& */
>   ops->db_valid_mask  &&
> -
>   /* both set, or both unset */
> - (!ops->db_vector_count == !ops->db_vector_mask) &&
> -
> + (!ops->db_vector_count == !ops->db_vector_mask) &&
>   ops->db_read&&
>   /* ops->db_set  && */
>   ops->db_clear   &&
> @@ -360,6 +364,8 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* ops->peer_db_read_mask   && */
>   /* ops->peer_db_set_mask&& */
>   /* ops->peer_db_clear_mask  && */
> +
> + /* Scrachpads interface is optional */
>   /* !ops->spad_is_unsafe == !ops->spad_count && */
>   !ops->spad_read == !ops->spad_count &&
>   !ops->spad_write == !ops->spad_count&&
> @@ -367,6 +373,7 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* !ops->peer_spad_read == !ops->spad_count && */
>   !ops->peer_spad_write == !ops->spad_count   &&
> 
> + /* Messaging interface is optional */
>   !ops->msg_inbits == !ops->msg_count &&
>   !ops->msg_outbits == !ops->msg_count&&
>   !ops->msg_read_sts == !ops->msg_count   &&
> @@ -387,13 +394,12 @@ struct ntb_client {
>   struct device_driverdrv;
>   const struct ntb_client_ops ops;
>  };
> -
>  #define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
> 
>  /**
>   * struct ntb_device - ntb device
>   * @dev: Linux device object.
> - * @pdev:Pci device entry of the ntb.
> + * @pdev:PCI device entry of the ntb.
>   * @topo:Detected topology of the ntb.
>   * @ops: See _dev_ops.
>   * @ctx: See _ctx_ops.
> @@ -414,7 +420,6 @@ struct ntb_dev {
>   /* block unregister until device is fully released */
>   struct completion   released;
>  };
> -
>  #define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
> 
>  /**
> @@ -511,7 +516,7 @@ void ntb_link_event(struct ntb_dev *ntb);
>   * multiple interrupt vectors for doorbells, the vector number indicates 
> which
>   * vector received the interrupt.  The vector number is relative to the first
>   * vector used for doorbells, starting at zero, and must be less than
> - ** ntb_db_vector_count().  The driver may call ntb_db_read() to check which
> + * ntb_db_vector_count().  The driver may call ntb_db_read() to check which
>   * doorbell bits need service, and ntb_db_vector_mask() to determine which of
>   * those bits are associated with the vector number.
>   */
> --
> 2.6.6




RE: [PATCH v3 9/9] NTB: Add ntb.h comments

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Signed-off-by: Serge Semin 
> ---
>  include/linux/ntb.h | 19 ---
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index 6d46179..dab0a1b 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -326,12 +326,17 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>  {
>   /* commented callbacks are not required: */
>   return
> + /* Port operations are required */

... for multiport devices.

>   !ops->peer_port_count == !ops->port_number  &&
>   !ops->peer_port_number == !ops->port_number &&
>   !ops->peer_port_idx == !ops->port_number&&
> +
> + /* Link operations are requiered */
>   ops->link_is_up &&
>   ops->link_enable&&
>   ops->link_disable   &&
> +
> + /* One or both MW interfaces should be developed */
>   ops->mw_count   &&
>   ops->mw_get_align   &&
>   (ops->mw_set_trans  ||
> @@ -341,12 +346,11 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>   ops->peer_mw_get_addr   &&
>   /* ops->peer_mw_clear_trans && */
> 
> + /* Doorbell operations are mostly required */
>   /* ops->db_is_unsafe&& */
>   ops->db_valid_mask  &&
> -
>   /* both set, or both unset */
> - (!ops->db_vector_count == !ops->db_vector_mask) &&
> -
> + (!ops->db_vector_count == !ops->db_vector_mask) &&
>   ops->db_read&&
>   /* ops->db_set  && */
>   ops->db_clear   &&
> @@ -360,6 +364,8 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* ops->peer_db_read_mask   && */
>   /* ops->peer_db_set_mask&& */
>   /* ops->peer_db_clear_mask  && */
> +
> + /* Scrachpads interface is optional */
>   /* !ops->spad_is_unsafe == !ops->spad_count && */
>   !ops->spad_read == !ops->spad_count &&
>   !ops->spad_write == !ops->spad_count&&
> @@ -367,6 +373,7 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops *ops)
>   /* !ops->peer_spad_read == !ops->spad_count && */
>   !ops->peer_spad_write == !ops->spad_count   &&
> 
> + /* Messaging interface is optional */
>   !ops->msg_inbits == !ops->msg_count &&
>   !ops->msg_outbits == !ops->msg_count&&
>   !ops->msg_read_sts == !ops->msg_count   &&
> @@ -387,13 +394,12 @@ struct ntb_client {
>   struct device_driverdrv;
>   const struct ntb_client_ops ops;
>  };
> -
>  #define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
> 
>  /**
>   * struct ntb_device - ntb device
>   * @dev: Linux device object.
> - * @pdev:Pci device entry of the ntb.
> + * @pdev:PCI device entry of the ntb.
>   * @topo:Detected topology of the ntb.
>   * @ops: See _dev_ops.
>   * @ctx: See _ctx_ops.
> @@ -414,7 +420,6 @@ struct ntb_dev {
>   /* block unregister until device is fully released */
>   struct completion   released;
>  };
> -
>  #define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
> 
>  /**
> @@ -511,7 +516,7 @@ void ntb_link_event(struct ntb_dev *ntb);
>   * multiple interrupt vectors for doorbells, the vector number indicates 
> which
>   * vector received the interrupt.  The vector number is relative to the first
>   * vector used for doorbells, starting at zero, and must be less than
> - ** ntb_db_vector_count().  The driver may call ntb_db_read() to check which
> + * ntb_db_vector_count().  The driver may call ntb_db_read() to check which
>   * doorbell bits need service, and ntb_db_vector_mask() to determine which of
>   * those bits are associated with the vector number.
>   */
> --
> 2.6.6




Re: [PATCH v3 1/4] mtd: lart: Rename partition defines to be prefixed with PART_

2016-12-13 Thread Boris Brezillon
On Fri,  9 Dec 2016 15:36:25 -0800
Florian Fainelli  wrote:

> In preparation for defining KERNEL_START on ARM, rename KERNEL_START to
> PART_KERNEL_START, and to be consistent, do this for all
> partition-related constants.
> 
> Signed-off-by: Florian Fainelli 

Acked-by: Boris Brezillon 

> ---
>  drivers/mtd/devices/lart.c | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
> index 82bd00af5cc3..268aae45b514 100644
> --- a/drivers/mtd/devices/lart.c
> +++ b/drivers/mtd/devices/lart.c
> @@ -75,18 +75,18 @@ static char module_name[] = "lart";
>  
>  /* blob */
>  #define NUM_BLOB_BLOCKS  FLASH_NUMBLOCKS_16m_PARAM
> -#define BLOB_START   0x
> -#define BLOB_LEN (NUM_BLOB_BLOCKS * 
> FLASH_BLOCKSIZE_PARAM)
> +#define PART_BLOB_START  0x
> +#define PART_BLOB_LEN(NUM_BLOB_BLOCKS * 
> FLASH_BLOCKSIZE_PARAM)
>  
>  /* kernel */
>  #define NUM_KERNEL_BLOCKS7
> -#define KERNEL_START (BLOB_START + BLOB_LEN)
> -#define KERNEL_LEN   (NUM_KERNEL_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
> +#define PART_KERNEL_START(PART_BLOB_START + PART_BLOB_LEN)
> +#define PART_KERNEL_LEN  (NUM_KERNEL_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
>  
>  /* initial ramdisk */
>  #define NUM_INITRD_BLOCKS24
> -#define INITRD_START (KERNEL_START + KERNEL_LEN)
> -#define INITRD_LEN   (NUM_INITRD_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
> +#define PART_INITRD_START(PART_KERNEL_START + PART_KERNEL_LEN)
> +#define PART_INITRD_LEN  (NUM_INITRD_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
>  
>  /*
>   * See section 4.0 in "3 Volt Fast Boot Block Flash Memory" Intel Datasheet
> @@ -587,20 +587,20 @@ static struct mtd_partition lart_partitions[] = {
>   /* blob */
>   {
>   .name   = "blob",
> - .offset = BLOB_START,
> - .size   = BLOB_LEN,
> + .offset = PART_BLOB_START,
> + .size   = PART_BLOB_LEN,
>   },
>   /* kernel */
>   {
>   .name   = "kernel",
> - .offset = KERNEL_START, /* MTDPART_OFS_APPEND */
> - .size   = KERNEL_LEN,
> + .offset = PART_KERNEL_START,/* MTDPART_OFS_APPEND */
> + .size   = PART_KERNEL_LEN,
>   },
>   /* initial ramdisk / file system */
>   {
>   .name   = "file system",
> - .offset = INITRD_START, /* MTDPART_OFS_APPEND */
> - .size   = INITRD_LEN,   /* MTDPART_SIZ_FULL */
> + .offset = PART_INITRD_START,/* MTDPART_OFS_APPEND */
> + .size   = PART_INITRD_LEN,  /* MTDPART_SIZ_FULL */
>   }
>  };
>  #define NUM_PARTITIONS ARRAY_SIZE(lart_partitions)



RE: [PATCH v3 5/9] NTB: Alter Scratchpads API to support multi-ports devices

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Even though there is no any real NTB hardware, which would have both more
> than two ports and Scratchpad registers, it is logically correct to have
> Scratchpad API accepting a peer port index as well. Intel/AMD drivers utilize
> Primary and Secondary topology to split Scratchpad between connected root
> devices. Since port-index API introduced, Intel/AMD NTB hardware drivers can
> use device port to determine which Scratchpad registers actually belong to
> local and peer devices. The same approach can be used if some potential
> hardware in future will be multi-port and have some set of Scratchpads.
> Here are the brief of changes in the API:
>  ntb_spad_count() - return number of Scratchpads per each port
>  ntb_peer_spad_addr(pidx, sidx) - address of Scratchpad register of the
> peer device with pidx-index
>  ntb_peer_spad_read(pidx, sidx) - read specified Scratchpad register of the
> peer with pidx-index
>  ntb_peer_spad_write(pidx, sidx) - write data to Scratchpad register of the
> peer with pidx-index
> 
> Since there is hardware which doesn't support Scratchpad registers, the
> corresponding API methods are now made optional.
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  drivers/ntb/hw/amd/ntb_hw_amd.c | 14 +++
>  drivers/ntb/hw/intel/ntb_hw_intel.c | 14 +++
>  drivers/ntb/ntb_transport.c | 17 -
>  drivers/ntb/test/ntb_perf.c |  6 +--
>  drivers/ntb/test/ntb_pingpong.c |  8 +++-
>  drivers/ntb/test/ntb_tool.c | 21 --
>  include/linux/ntb.h | 76 
> +++--
>  7 files changed, 98 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
> index 6a41c38..bc537aa 100644
> --- a/drivers/ntb/hw/amd/ntb_hw_amd.c
> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
> @@ -433,30 +433,30 @@ static int amd_ntb_spad_write(struct ntb_dev *ntb,
>   return 0;
>  }
> 
> -static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int idx)
> +static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>   void __iomem *mmio = ndev->self_mmio;
>   u32 offset;
> 
> - if (idx < 0 || idx >= ndev->spad_count)
> + if (sidx < 0 || sidx >= ndev->spad_count)
>   return -EINVAL;
> 
> - offset = ndev->peer_spad + (idx << 2);
> + offset = ndev->peer_spad + (sidx << 2);
>   return readl(mmio + AMD_SPAD_OFFSET + offset);
>  }
> 
> -static int amd_ntb_peer_spad_write(struct ntb_dev *ntb,
> -int idx, u32 val)
> +static int amd_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
> +int sidx, u32 val)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>   void __iomem *mmio = ndev->self_mmio;
>   u32 offset;
> 
> - if (idx < 0 || idx >= ndev->spad_count)
> + if (sidx < 0 || sidx >= ndev->spad_count)
>   return -EINVAL;
> 
> - offset = ndev->peer_spad + (idx << 2);
> + offset = ndev->peer_spad + (sidx << 2);
>   writel(val, mmio + AMD_SPAD_OFFSET + offset);
> 
>   return 0;
> diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c 
> b/drivers/ntb/hw/intel/ntb_hw_intel.c
> index 4b84012..7bb14cb 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_intel.c
> +++ b/drivers/ntb/hw/intel/ntb_hw_intel.c
> @@ -1409,30 +1409,30 @@ static int intel_ntb_spad_write(struct ntb_dev *ntb,
>  ndev->self_reg->spad);
>  }
> 
> -static int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int idx,
> +static int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx,
>   phys_addr_t *spad_addr)
>  {
>   struct intel_ntb_dev *ndev = ntb_ndev(ntb);
> 
> - return ndev_spad_addr(ndev, idx, spad_addr, ndev->peer_addr,
> + return ndev_spad_addr(ndev, sidx, spad_addr, ndev->peer_addr,
> ndev->peer_reg->spad);
>  }
> 
> -static u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int idx)
> +static u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
>  {
>   struct intel_ntb_dev *ndev = ntb_ndev(ntb);
> 
> - return ndev_spad_read(ndev, idx,
> + return ndev_spad_read(ndev, sidx,
> ndev->peer_mmio +
> ndev->peer_reg->spad);
>  }
> 
> -static int intel_ntb_peer_spad_write(struct ntb_dev *ntb,
> -  int idx, u32 val)
> +static int intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
> +  int sidx, u32 val)
>  {
>   struct intel_ntb_dev *ndev = ntb_ndev(ntb);
> 
> - return ndev_spad_write(ndev, idx, val,
> + return ndev_spad_write(ndev, sidx, val,
>  ndev->peer_mmio +
>  ndev->peer_reg->spad);
>  }
> diff --git 

Re: [PATCH v3 1/4] mtd: lart: Rename partition defines to be prefixed with PART_

2016-12-13 Thread Boris Brezillon
On Fri,  9 Dec 2016 15:36:25 -0800
Florian Fainelli  wrote:

> In preparation for defining KERNEL_START on ARM, rename KERNEL_START to
> PART_KERNEL_START, and to be consistent, do this for all
> partition-related constants.
> 
> Signed-off-by: Florian Fainelli 

Acked-by: Boris Brezillon 

> ---
>  drivers/mtd/devices/lart.c | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
> index 82bd00af5cc3..268aae45b514 100644
> --- a/drivers/mtd/devices/lart.c
> +++ b/drivers/mtd/devices/lart.c
> @@ -75,18 +75,18 @@ static char module_name[] = "lart";
>  
>  /* blob */
>  #define NUM_BLOB_BLOCKS  FLASH_NUMBLOCKS_16m_PARAM
> -#define BLOB_START   0x
> -#define BLOB_LEN (NUM_BLOB_BLOCKS * 
> FLASH_BLOCKSIZE_PARAM)
> +#define PART_BLOB_START  0x
> +#define PART_BLOB_LEN(NUM_BLOB_BLOCKS * 
> FLASH_BLOCKSIZE_PARAM)
>  
>  /* kernel */
>  #define NUM_KERNEL_BLOCKS7
> -#define KERNEL_START (BLOB_START + BLOB_LEN)
> -#define KERNEL_LEN   (NUM_KERNEL_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
> +#define PART_KERNEL_START(PART_BLOB_START + PART_BLOB_LEN)
> +#define PART_KERNEL_LEN  (NUM_KERNEL_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
>  
>  /* initial ramdisk */
>  #define NUM_INITRD_BLOCKS24
> -#define INITRD_START (KERNEL_START + KERNEL_LEN)
> -#define INITRD_LEN   (NUM_INITRD_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
> +#define PART_INITRD_START(PART_KERNEL_START + PART_KERNEL_LEN)
> +#define PART_INITRD_LEN  (NUM_INITRD_BLOCKS * 
> FLASH_BLOCKSIZE_MAIN)
>  
>  /*
>   * See section 4.0 in "3 Volt Fast Boot Block Flash Memory" Intel Datasheet
> @@ -587,20 +587,20 @@ static struct mtd_partition lart_partitions[] = {
>   /* blob */
>   {
>   .name   = "blob",
> - .offset = BLOB_START,
> - .size   = BLOB_LEN,
> + .offset = PART_BLOB_START,
> + .size   = PART_BLOB_LEN,
>   },
>   /* kernel */
>   {
>   .name   = "kernel",
> - .offset = KERNEL_START, /* MTDPART_OFS_APPEND */
> - .size   = KERNEL_LEN,
> + .offset = PART_KERNEL_START,/* MTDPART_OFS_APPEND */
> + .size   = PART_KERNEL_LEN,
>   },
>   /* initial ramdisk / file system */
>   {
>   .name   = "file system",
> - .offset = INITRD_START, /* MTDPART_OFS_APPEND */
> - .size   = INITRD_LEN,   /* MTDPART_SIZ_FULL */
> + .offset = PART_INITRD_START,/* MTDPART_OFS_APPEND */
> + .size   = PART_INITRD_LEN,  /* MTDPART_SIZ_FULL */
>   }
>  };
>  #define NUM_PARTITIONS ARRAY_SIZE(lart_partitions)



RE: [PATCH v3 5/9] NTB: Alter Scratchpads API to support multi-ports devices

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Even though there is no any real NTB hardware, which would have both more
> than two ports and Scratchpad registers, it is logically correct to have
> Scratchpad API accepting a peer port index as well. Intel/AMD drivers utilize
> Primary and Secondary topology to split Scratchpad between connected root
> devices. Since port-index API introduced, Intel/AMD NTB hardware drivers can
> use device port to determine which Scratchpad registers actually belong to
> local and peer devices. The same approach can be used if some potential
> hardware in future will be multi-port and have some set of Scratchpads.
> Here are the brief of changes in the API:
>  ntb_spad_count() - return number of Scratchpads per each port
>  ntb_peer_spad_addr(pidx, sidx) - address of Scratchpad register of the
> peer device with pidx-index
>  ntb_peer_spad_read(pidx, sidx) - read specified Scratchpad register of the
> peer with pidx-index
>  ntb_peer_spad_write(pidx, sidx) - write data to Scratchpad register of the
> peer with pidx-index
> 
> Since there is hardware which doesn't support Scratchpad registers, the
> corresponding API methods are now made optional.
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  drivers/ntb/hw/amd/ntb_hw_amd.c | 14 +++
>  drivers/ntb/hw/intel/ntb_hw_intel.c | 14 +++
>  drivers/ntb/ntb_transport.c | 17 -
>  drivers/ntb/test/ntb_perf.c |  6 +--
>  drivers/ntb/test/ntb_pingpong.c |  8 +++-
>  drivers/ntb/test/ntb_tool.c | 21 --
>  include/linux/ntb.h | 76 
> +++--
>  7 files changed, 98 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
> index 6a41c38..bc537aa 100644
> --- a/drivers/ntb/hw/amd/ntb_hw_amd.c
> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
> @@ -433,30 +433,30 @@ static int amd_ntb_spad_write(struct ntb_dev *ntb,
>   return 0;
>  }
> 
> -static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int idx)
> +static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>   void __iomem *mmio = ndev->self_mmio;
>   u32 offset;
> 
> - if (idx < 0 || idx >= ndev->spad_count)
> + if (sidx < 0 || sidx >= ndev->spad_count)
>   return -EINVAL;
> 
> - offset = ndev->peer_spad + (idx << 2);
> + offset = ndev->peer_spad + (sidx << 2);
>   return readl(mmio + AMD_SPAD_OFFSET + offset);
>  }
> 
> -static int amd_ntb_peer_spad_write(struct ntb_dev *ntb,
> -int idx, u32 val)
> +static int amd_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
> +int sidx, u32 val)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>   void __iomem *mmio = ndev->self_mmio;
>   u32 offset;
> 
> - if (idx < 0 || idx >= ndev->spad_count)
> + if (sidx < 0 || sidx >= ndev->spad_count)
>   return -EINVAL;
> 
> - offset = ndev->peer_spad + (idx << 2);
> + offset = ndev->peer_spad + (sidx << 2);
>   writel(val, mmio + AMD_SPAD_OFFSET + offset);
> 
>   return 0;
> diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c 
> b/drivers/ntb/hw/intel/ntb_hw_intel.c
> index 4b84012..7bb14cb 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_intel.c
> +++ b/drivers/ntb/hw/intel/ntb_hw_intel.c
> @@ -1409,30 +1409,30 @@ static int intel_ntb_spad_write(struct ntb_dev *ntb,
>  ndev->self_reg->spad);
>  }
> 
> -static int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int idx,
> +static int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx,
>   phys_addr_t *spad_addr)
>  {
>   struct intel_ntb_dev *ndev = ntb_ndev(ntb);
> 
> - return ndev_spad_addr(ndev, idx, spad_addr, ndev->peer_addr,
> + return ndev_spad_addr(ndev, sidx, spad_addr, ndev->peer_addr,
> ndev->peer_reg->spad);
>  }
> 
> -static u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int idx)
> +static u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
>  {
>   struct intel_ntb_dev *ndev = ntb_ndev(ntb);
> 
> - return ndev_spad_read(ndev, idx,
> + return ndev_spad_read(ndev, sidx,
> ndev->peer_mmio +
> ndev->peer_reg->spad);
>  }
> 
> -static int intel_ntb_peer_spad_write(struct ntb_dev *ntb,
> -  int idx, u32 val)
> +static int intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
> +  int sidx, u32 val)
>  {
>   struct intel_ntb_dev *ndev = ntb_ndev(ntb);
> 
> - return ndev_spad_write(ndev, idx, val,
> + return ndev_spad_write(ndev, sidx, val,
>  ndev->peer_mmio +
>  ndev->peer_reg->spad);
>  }
> diff --git a/drivers/ntb/ntb_transport.c 

RE: [PATCH v3 4/9] NTB: Alter MW API to support multi-ports devices

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Multi-port NTB devices permit to share a memory between all accessible peers.
> Memory Windows API is altered to correspondingly initialize and map memory
> windows for such devices:
>  ntb_mw_count(pidx); - number of inbound memory windows, which can be 
> allocated
> for shared buffer with specified peer device.
>  ntb_mw_get_align(pidx, widx); - get alignment and size restriction parameters
> to properly allocate inbound memory region.
>  ntb_peer_mw_count(); - get number of outbound memory windows.
>  ntb_peer_mw_get_addr(widx); - get mapping address of an outbound memory 
> window
> 
> If hardware supports inbound translation configured on the local ntb port:
>  ntb_mw_set_trans(pidx, widx); - set translation address of allocated inbound
> memory window so a peer device could access it.
>  ntb_mw_clear_trans(pidx, widx); - clear the translation address of an inbound
> memory window.
> 
> If hardware supports outbound translation configured on the peer ntb port:
>  ntb_peer_mw_set_trans(pidx, widx); - set translation address of a memory
> window retrieved from a peer device
>  ntb_peer_mw_clear_trans(pidx, widx); - clear the translation address of an
> outbound memory window
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  drivers/ntb/hw/amd/ntb_hw_amd.c |  68 +---
>  drivers/ntb/hw/intel/ntb_hw_intel.c |  90 
>  drivers/ntb/ntb.c   |   2 +
>  drivers/ntb/ntb_transport.c |  21 +++-
>  drivers/ntb/test/ntb_perf.c |  17 ++-
>  drivers/ntb/test/ntb_tool.c |  43 +---
>  include/linux/ntb.h | 208 
> 
>  7 files changed, 342 insertions(+), 107 deletions(-)
> 
> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
> index 4d8d0bd..6a41c38 100644
> --- a/drivers/ntb/hw/amd/ntb_hw_amd.c
> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
> @@ -5,6 +5,7 @@
>   *   GPL LICENSE SUMMARY
>   *
>   *   Copyright (C) 2016 Advanced Micro Devices, Inc. All Rights Reserved.
> + *   Copyright (C) 2016 T-Platforms. All Rights Reserved.
>   *
>   *   This program is free software; you can redistribute it and/or modify
>   *   it under the terms of version 2 of the GNU General Public License as
> @@ -13,6 +14,7 @@
>   *   BSD LICENSE
>   *
>   *   Copyright (C) 2016 Advanced Micro Devices, Inc. All Rights Reserved.
> + *   Copyright (C) 2016 T-Platforms. All Rights Reserved.
>   *
>   *   Redistribution and use in source and binary forms, with or without
>   *   modification, are permitted provided that the following conditions
> @@ -79,40 +81,42 @@ static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int 
> idx)
>   return 1 << idx;
>  }
> 
> -static int amd_ntb_mw_count(struct ntb_dev *ntb)
> +static int amd_ntb_mw_count(struct ntb_dev *ntb, int pidx)
>  {
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
>   return ntb_ndev(ntb)->mw_count;
>  }
> 
> -static int amd_ntb_mw_get_range(struct ntb_dev *ntb, int idx,
> - phys_addr_t *base,
> - resource_size_t *size,
> - resource_size_t *align,
> - resource_size_t *align_size)
> +static int amd_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int idx,
> + resource_size_t *addr_align,
> + resource_size_t *size_align,
> + resource_size_t *size_max)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>   int bar;
> 
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
>   bar = ndev_mw_to_bar(ndev, idx);
>   if (bar < 0)
>   return bar;
> 
> - if (base)
> - *base = pci_resource_start(ndev->ntb.pdev, bar);
> -
> - if (size)
> - *size = pci_resource_len(ndev->ntb.pdev, bar);
> + if (addr_align)
> + *addr_align = SZ_4K;
> 
> - if (align)
> - *align = SZ_4K;
> + if (size_align)
> + *size_align = 1;
> 
> - if (align_size)
> - *align_size = 1;
> + if (size_max)
> + *size_max = pci_resource_len(ndev->ntb.pdev, bar);
> 
>   return 0;
>  }
> 
> -static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
> +static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
>   dma_addr_t addr, resource_size_t size)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
> @@ -122,6 +126,9 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int 
> idx,
>   u64 base_addr, limit, reg_val;
>   int bar;
> 
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
>   bar = ndev_mw_to_bar(ndev, idx);
>   if (bar < 0)
>   return bar;
> @@ -285,6 +292,31 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb)
>  

RE: [PATCH v3 4/9] NTB: Alter MW API to support multi-ports devices

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> Multi-port NTB devices permit to share a memory between all accessible peers.
> Memory Windows API is altered to correspondingly initialize and map memory
> windows for such devices:
>  ntb_mw_count(pidx); - number of inbound memory windows, which can be 
> allocated
> for shared buffer with specified peer device.
>  ntb_mw_get_align(pidx, widx); - get alignment and size restriction parameters
> to properly allocate inbound memory region.
>  ntb_peer_mw_count(); - get number of outbound memory windows.
>  ntb_peer_mw_get_addr(widx); - get mapping address of an outbound memory 
> window
> 
> If hardware supports inbound translation configured on the local ntb port:
>  ntb_mw_set_trans(pidx, widx); - set translation address of allocated inbound
> memory window so a peer device could access it.
>  ntb_mw_clear_trans(pidx, widx); - clear the translation address of an inbound
> memory window.
> 
> If hardware supports outbound translation configured on the peer ntb port:
>  ntb_peer_mw_set_trans(pidx, widx); - set translation address of a memory
> window retrieved from a peer device
>  ntb_peer_mw_clear_trans(pidx, widx); - clear the translation address of an
> outbound memory window
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  drivers/ntb/hw/amd/ntb_hw_amd.c |  68 +---
>  drivers/ntb/hw/intel/ntb_hw_intel.c |  90 
>  drivers/ntb/ntb.c   |   2 +
>  drivers/ntb/ntb_transport.c |  21 +++-
>  drivers/ntb/test/ntb_perf.c |  17 ++-
>  drivers/ntb/test/ntb_tool.c |  43 +---
>  include/linux/ntb.h | 208 
> 
>  7 files changed, 342 insertions(+), 107 deletions(-)
> 
> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
> index 4d8d0bd..6a41c38 100644
> --- a/drivers/ntb/hw/amd/ntb_hw_amd.c
> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
> @@ -5,6 +5,7 @@
>   *   GPL LICENSE SUMMARY
>   *
>   *   Copyright (C) 2016 Advanced Micro Devices, Inc. All Rights Reserved.
> + *   Copyright (C) 2016 T-Platforms. All Rights Reserved.
>   *
>   *   This program is free software; you can redistribute it and/or modify
>   *   it under the terms of version 2 of the GNU General Public License as
> @@ -13,6 +14,7 @@
>   *   BSD LICENSE
>   *
>   *   Copyright (C) 2016 Advanced Micro Devices, Inc. All Rights Reserved.
> + *   Copyright (C) 2016 T-Platforms. All Rights Reserved.
>   *
>   *   Redistribution and use in source and binary forms, with or without
>   *   modification, are permitted provided that the following conditions
> @@ -79,40 +81,42 @@ static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int 
> idx)
>   return 1 << idx;
>  }
> 
> -static int amd_ntb_mw_count(struct ntb_dev *ntb)
> +static int amd_ntb_mw_count(struct ntb_dev *ntb, int pidx)
>  {
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
>   return ntb_ndev(ntb)->mw_count;
>  }
> 
> -static int amd_ntb_mw_get_range(struct ntb_dev *ntb, int idx,
> - phys_addr_t *base,
> - resource_size_t *size,
> - resource_size_t *align,
> - resource_size_t *align_size)
> +static int amd_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int idx,
> + resource_size_t *addr_align,
> + resource_size_t *size_align,
> + resource_size_t *size_max)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>   int bar;
> 
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
>   bar = ndev_mw_to_bar(ndev, idx);
>   if (bar < 0)
>   return bar;
> 
> - if (base)
> - *base = pci_resource_start(ndev->ntb.pdev, bar);
> -
> - if (size)
> - *size = pci_resource_len(ndev->ntb.pdev, bar);
> + if (addr_align)
> + *addr_align = SZ_4K;
> 
> - if (align)
> - *align = SZ_4K;
> + if (size_align)
> + *size_align = 1;
> 
> - if (align_size)
> - *align_size = 1;
> + if (size_max)
> + *size_max = pci_resource_len(ndev->ntb.pdev, bar);
> 
>   return 0;
>  }
> 
> -static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
> +static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
>   dma_addr_t addr, resource_size_t size)
>  {
>   struct amd_ntb_dev *ndev = ntb_ndev(ntb);
> @@ -122,6 +126,9 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int 
> idx,
>   u64 base_addr, limit, reg_val;
>   int bar;
> 
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
>   bar = ndev_mw_to_bar(ndev, idx);
>   if (bar < 0)
>   return bar;
> @@ -285,6 +292,31 @@ static int amd_ntb_link_disable(struct ntb_dev *ntb)
>   return 0;
>  }
> 
> +static int 

RE: [PATCH v3 1/9] NTB: Make link-state API being declared first

2016-12-13 Thread Allen Hubbe
From: Serge Semin 
> Since link operations are usually performed before memory window access
> operations, it's logically better to declare link-related API before any
> of MW/Doorbell/Scratchpad methods.
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  include/linux/ntb.h | 137 
> ++--
>  1 file changed, 69 insertions(+), 68 deletions(-)
> 
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index 6f47562..5d1f260 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -179,13 +179,13 @@ static inline int ntb_ctx_ops_is_valid(const struct 
> ntb_ctx_ops
> *ops)
> 
>  /**
>   * struct ntb_ctx_ops - ntb device operations
> + * @link_is_up:  See ntb_link_is_up().
> + * @link_enable: See ntb_link_enable().
> + * @link_disable:See ntb_link_disable().
>   * @mw_count:See ntb_mw_count().
>   * @mw_get_range:See ntb_mw_get_range().
>   * @mw_set_trans:See ntb_mw_set_trans().
>   * @mw_clear_trans:  See ntb_mw_clear_trans().
> - * @link_is_up:  See ntb_link_is_up().
> - * @link_enable: See ntb_link_enable().
> - * @link_disable:See ntb_link_disable().
>   * @db_is_unsafe:See ntb_db_is_unsafe().
>   * @db_valid_mask:   See ntb_db_valid_mask().
>   * @db_vector_count: See ntb_db_vector_count().
> @@ -212,6 +212,12 @@ static inline int ntb_ctx_ops_is_valid(const struct 
> ntb_ctx_ops *ops)
>   * @peer_spad_write: See ntb_peer_spad_write().
>   */
>  struct ntb_dev_ops {
> + int (*link_is_up)(struct ntb_dev *ntb,
> +   enum ntb_speed *speed, enum ntb_width *width);
> + int (*link_enable)(struct ntb_dev *ntb,
> +enum ntb_speed max_speed, enum ntb_width max_width);
> + int (*link_disable)(struct ntb_dev *ntb);
> +
>   int (*mw_count)(struct ntb_dev *ntb);
>   int (*mw_get_range)(struct ntb_dev *ntb, int idx,
>   phys_addr_t *base, resource_size_t *size,
> @@ -220,12 +226,6 @@ struct ntb_dev_ops {
>   dma_addr_t addr, resource_size_t size);
>   int (*mw_clear_trans)(struct ntb_dev *ntb, int idx);
> 
> - int (*link_is_up)(struct ntb_dev *ntb,
> -   enum ntb_speed *speed, enum ntb_width *width);
> - int (*link_enable)(struct ntb_dev *ntb,
> -enum ntb_speed max_speed, enum ntb_width max_width);
> - int (*link_disable)(struct ntb_dev *ntb);
> -
>   int (*db_is_unsafe)(struct ntb_dev *ntb);
>   u64 (*db_valid_mask)(struct ntb_dev *ntb);
>   int (*db_vector_count)(struct ntb_dev *ntb);
> @@ -265,13 +265,14 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>  {
>   /* commented callbacks are not required: */
>   return
> + ops->link_is_up &&
> + ops->link_enable&&
> + ops->link_disable   &&
>   ops->mw_count   &&
>   ops->mw_get_range   &&
>   ops->mw_set_trans   &&
>   /* ops->mw_clear_trans  && */
> - ops->link_is_up &&
> - ops->link_enable&&
> - ops->link_disable   &&
> +
>   /* ops->db_is_unsafe&& */
>   ops->db_valid_mask  &&
> 
> @@ -441,6 +442,62 @@ void ntb_link_event(struct ntb_dev *ntb);
>  void ntb_db_event(struct ntb_dev *ntb, int vector);
> 
>  /**
> + * ntb_link_is_up() - get the current ntb link state
> + * @ntb: NTB device context.
> + * @speed:   OUT - The link speed expressed as PCIe generation number.
> + * @width:   OUT - The link width expressed as the number of PCIe lanes.
> + *
> + * Get the current state of the ntb link.  It is recommended to query the 
> link
> + * state once after every link event.  It is safe to query the link state in
> + * the context of the link event callback.
> + *
> + * Return: One if the link is up, zero if the link is down, otherwise a
> + *   negative value indicating the error number.
> + */
> +static inline int ntb_link_is_up(struct ntb_dev *ntb,
> +  enum ntb_speed *speed, enum ntb_width *width)
> +{
> + return ntb->ops->link_is_up(ntb, speed, width);
> +}
> +
> +/**
> + * ntb_link_enable() - enable the link on the secondary side of the ntb
> + * @ntb: NTB device context.
> + * @max_speed:   The maximum link speed expressed as PCIe generation 
> number.
> + * @max_width:   The maximum link width expressed as the number of PCIe 
> lanes.
> + *
> + * Enable the link on the secondary side of the ntb.  This can only be done
> + * from the primary side of the ntb in primary or b2b topology.  The ntb 
> device
> + * 

RE: [PATCH v3 1/9] NTB: Make link-state API being declared first

2016-12-13 Thread Allen Hubbe
From: Serge Semin 
> Since link operations are usually performed before memory window access
> operations, it's logically better to declare link-related API before any
> of MW/Doorbell/Scratchpad methods.
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  include/linux/ntb.h | 137 
> ++--
>  1 file changed, 69 insertions(+), 68 deletions(-)
> 
> diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> index 6f47562..5d1f260 100644
> --- a/include/linux/ntb.h
> +++ b/include/linux/ntb.h
> @@ -179,13 +179,13 @@ static inline int ntb_ctx_ops_is_valid(const struct 
> ntb_ctx_ops
> *ops)
> 
>  /**
>   * struct ntb_ctx_ops - ntb device operations
> + * @link_is_up:  See ntb_link_is_up().
> + * @link_enable: See ntb_link_enable().
> + * @link_disable:See ntb_link_disable().
>   * @mw_count:See ntb_mw_count().
>   * @mw_get_range:See ntb_mw_get_range().
>   * @mw_set_trans:See ntb_mw_set_trans().
>   * @mw_clear_trans:  See ntb_mw_clear_trans().
> - * @link_is_up:  See ntb_link_is_up().
> - * @link_enable: See ntb_link_enable().
> - * @link_disable:See ntb_link_disable().
>   * @db_is_unsafe:See ntb_db_is_unsafe().
>   * @db_valid_mask:   See ntb_db_valid_mask().
>   * @db_vector_count: See ntb_db_vector_count().
> @@ -212,6 +212,12 @@ static inline int ntb_ctx_ops_is_valid(const struct 
> ntb_ctx_ops *ops)
>   * @peer_spad_write: See ntb_peer_spad_write().
>   */
>  struct ntb_dev_ops {
> + int (*link_is_up)(struct ntb_dev *ntb,
> +   enum ntb_speed *speed, enum ntb_width *width);
> + int (*link_enable)(struct ntb_dev *ntb,
> +enum ntb_speed max_speed, enum ntb_width max_width);
> + int (*link_disable)(struct ntb_dev *ntb);
> +
>   int (*mw_count)(struct ntb_dev *ntb);
>   int (*mw_get_range)(struct ntb_dev *ntb, int idx,
>   phys_addr_t *base, resource_size_t *size,
> @@ -220,12 +226,6 @@ struct ntb_dev_ops {
>   dma_addr_t addr, resource_size_t size);
>   int (*mw_clear_trans)(struct ntb_dev *ntb, int idx);
> 
> - int (*link_is_up)(struct ntb_dev *ntb,
> -   enum ntb_speed *speed, enum ntb_width *width);
> - int (*link_enable)(struct ntb_dev *ntb,
> -enum ntb_speed max_speed, enum ntb_width max_width);
> - int (*link_disable)(struct ntb_dev *ntb);
> -
>   int (*db_is_unsafe)(struct ntb_dev *ntb);
>   u64 (*db_valid_mask)(struct ntb_dev *ntb);
>   int (*db_vector_count)(struct ntb_dev *ntb);
> @@ -265,13 +265,14 @@ static inline int ntb_dev_ops_is_valid(const struct 
> ntb_dev_ops
> *ops)
>  {
>   /* commented callbacks are not required: */
>   return
> + ops->link_is_up &&
> + ops->link_enable&&
> + ops->link_disable   &&
>   ops->mw_count   &&
>   ops->mw_get_range   &&
>   ops->mw_set_trans   &&
>   /* ops->mw_clear_trans  && */
> - ops->link_is_up &&
> - ops->link_enable&&
> - ops->link_disable   &&
> +
>   /* ops->db_is_unsafe&& */
>   ops->db_valid_mask  &&
> 
> @@ -441,6 +442,62 @@ void ntb_link_event(struct ntb_dev *ntb);
>  void ntb_db_event(struct ntb_dev *ntb, int vector);
> 
>  /**
> + * ntb_link_is_up() - get the current ntb link state
> + * @ntb: NTB device context.
> + * @speed:   OUT - The link speed expressed as PCIe generation number.
> + * @width:   OUT - The link width expressed as the number of PCIe lanes.
> + *
> + * Get the current state of the ntb link.  It is recommended to query the 
> link
> + * state once after every link event.  It is safe to query the link state in
> + * the context of the link event callback.
> + *
> + * Return: One if the link is up, zero if the link is down, otherwise a
> + *   negative value indicating the error number.
> + */
> +static inline int ntb_link_is_up(struct ntb_dev *ntb,
> +  enum ntb_speed *speed, enum ntb_width *width)
> +{
> + return ntb->ops->link_is_up(ntb, speed, width);
> +}
> +
> +/**
> + * ntb_link_enable() - enable the link on the secondary side of the ntb
> + * @ntb: NTB device context.
> + * @max_speed:   The maximum link speed expressed as PCIe generation 
> number.
> + * @max_width:   The maximum link width expressed as the number of PCIe 
> lanes.
> + *
> + * Enable the link on the secondary side of the ntb.  This can only be done
> + * from the primary side of the ntb in primary or b2b topology.  The ntb 
> device
> + * should train the link to its maximum speed and 

RE: [PATCH v3 2/9] NTB: Add indexed ports NTB API

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> There is some NTB hardware, which can combine more than just two domains
> over NTB. For instance, some IDT PCIe-switches can have NTB-functions
> activated on more than two-ports. The different domains are distinguished
> by ports they are connected to. So the new port-related methods are added to
> the NTB API:
>  ntb_port_number() - return local port
>  ntb_peer_port_count() - return number of peers local port can connect to
>  ntb_peer_port_number(pdix) - return port number by it index
>  ntb_peer_port_idx(port) - return port index by it number
> 
> Current test-drivers aren't changed much. They still support two-ports devices
> for the time being while multi-ports hardware drivers aren't added.
> 
> By default port-related API is declared for two-ports hardware.
> So corresponding hardware drivers won't need to implement it.
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  drivers/ntb/ntb.c   |  54 ++
>  drivers/ntb/ntb_transport.c |   6 ++
>  drivers/ntb/test/ntb_perf.c |   4 ++
>  drivers/ntb/test/ntb_pingpong.c |   6 ++
>  drivers/ntb/test/ntb_tool.c |   5 ++
>  include/linux/ntb.h | 156 
> 
>  6 files changed, 231 insertions(+)
> 
> diff --git a/drivers/ntb/ntb.c b/drivers/ntb/ntb.c
> index 2e25307..1e92e52 100644
> --- a/drivers/ntb/ntb.c
> +++ b/drivers/ntb/ntb.c
> @@ -191,6 +191,60 @@ void ntb_db_event(struct ntb_dev *ntb, int vector)
>  }
>  EXPORT_SYMBOL(ntb_db_event);
> 
> +int ntb_default_port_number(struct ntb_dev *ntb)
> +{
> + switch (ntb->topo) {
> + case NTB_TOPO_PRI:
> + case NTB_TOPO_B2B_USD:
> + return NTB_PORT_PRI_USD;
> + case NTB_TOPO_SEC:
> + case NTB_TOPO_B2B_DSD:
> + return NTB_PORT_SEC_DSD;
> + default:
> + break;
> + }
> +
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL(ntb_default_port_number);
> +
> +int ntb_default_peer_port_count(struct ntb_dev *ntb)
> +{
> + return NTB_DEF_PEER_CNT;
> +}
> +EXPORT_SYMBOL(ntb_default_peer_port_count);
> +
> +int ntb_default_peer_port_number(struct ntb_dev *ntb, int pidx)
> +{
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
> + switch (ntb->topo) {
> + case NTB_TOPO_PRI:
> + case NTB_TOPO_B2B_USD:
> + return NTB_PORT_SEC_DSD;
> + case NTB_TOPO_SEC:
> + case NTB_TOPO_B2B_DSD:
> + return NTB_PORT_PRI_USD;
> + default:
> + break;
> + }
> +
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL(ntb_default_peer_port_number);
> +
> +int ntb_default_peer_port_idx(struct ntb_dev *ntb, int port)
> +{
> + int peer_port = ntb_default_peer_port_number(ntb, NTB_DEF_PEER_IDX);
> +
> + if (peer_port == -EINVAL || port != peer_port)
> + return -EINVAL;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(ntb_default_peer_port_idx);
> +
>  static int ntb_probe(struct device *dev)
>  {
>   struct ntb_dev *ntb;
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index 4eb8adb..10518b7 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -94,6 +94,9 @@ MODULE_PARM_DESC(use_dma, "Use DMA engine to perform large 
> data copy");
> 
>  static struct dentry *nt_debugfs_dir;
> 
> +/* Only two-ports NTB devices are supported */
> +#define PIDX NTB_DEF_PEER_IDX
> +
>  struct ntb_queue_entry {
>   /* ntb_queue list reference */
>   struct list_head entry;
> @@ -1083,6 +1086,9 @@ static int ntb_transport_probe(struct ntb_client *self, 
> struct
> ntb_dev *ndev)
>   dev_dbg(>dev,
>   "scratchpad is unsafe, proceed anyway...\n");
> 
> + if (ntb_peer_port_count(ndev) != NTB_DEF_PEER_CNT)
> + dev_warn(>dev, "Multi-port NTB devices unsupported\n");
> +
>   node = dev_to_node(>dev);
> 
>   nt = kzalloc_node(sizeof(*nt), GFP_KERNEL, node);
> diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
> index e75d4fd..c908b3a 100644
> --- a/drivers/ntb/test/ntb_perf.c
> +++ b/drivers/ntb/test/ntb_perf.c
> @@ -76,6 +76,7 @@
>  #define DMA_RETRIES  20
>  #define SZ_4G(1ULL << 32)
>  #define MAX_SEG_ORDER20 /* no larger than 1M for kmalloc 
> buffer */
> +#define PIDX NTB_DEF_PEER_IDX
> 
>  MODULE_LICENSE(DRIVER_LICENSE);
>  MODULE_VERSION(DRIVER_VERSION);
> @@ -764,6 +765,9 @@ static int perf_probe(struct ntb_client *client, struct 
> ntb_dev *ntb)
>   return -EIO;
>   }
> 
> + if (ntb_peer_port_count(ntb) != NTB_DEF_PEER_CNT)
> + dev_warn(>dev, "Multi-port NTB devices unsupported\n");
> +
>   node = dev_to_node(>dev);
> 
>   perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node);
> diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c
> index 4358611..12f8b40 100644
> --- 

RE: [PATCH v3 2/9] NTB: Add indexed ports NTB API

2016-12-13 Thread Allen Hubbe
From: Serge Semin
> There is some NTB hardware, which can combine more than just two domains
> over NTB. For instance, some IDT PCIe-switches can have NTB-functions
> activated on more than two-ports. The different domains are distinguished
> by ports they are connected to. So the new port-related methods are added to
> the NTB API:
>  ntb_port_number() - return local port
>  ntb_peer_port_count() - return number of peers local port can connect to
>  ntb_peer_port_number(pdix) - return port number by it index
>  ntb_peer_port_idx(port) - return port index by it number
> 
> Current test-drivers aren't changed much. They still support two-ports devices
> for the time being while multi-ports hardware drivers aren't added.
> 
> By default port-related API is declared for two-ports hardware.
> So corresponding hardware drivers won't need to implement it.
> 
> Signed-off-by: Serge Semin 

Acked-by: Allen Hubbe 

> ---
>  drivers/ntb/ntb.c   |  54 ++
>  drivers/ntb/ntb_transport.c |   6 ++
>  drivers/ntb/test/ntb_perf.c |   4 ++
>  drivers/ntb/test/ntb_pingpong.c |   6 ++
>  drivers/ntb/test/ntb_tool.c |   5 ++
>  include/linux/ntb.h | 156 
> 
>  6 files changed, 231 insertions(+)
> 
> diff --git a/drivers/ntb/ntb.c b/drivers/ntb/ntb.c
> index 2e25307..1e92e52 100644
> --- a/drivers/ntb/ntb.c
> +++ b/drivers/ntb/ntb.c
> @@ -191,6 +191,60 @@ void ntb_db_event(struct ntb_dev *ntb, int vector)
>  }
>  EXPORT_SYMBOL(ntb_db_event);
> 
> +int ntb_default_port_number(struct ntb_dev *ntb)
> +{
> + switch (ntb->topo) {
> + case NTB_TOPO_PRI:
> + case NTB_TOPO_B2B_USD:
> + return NTB_PORT_PRI_USD;
> + case NTB_TOPO_SEC:
> + case NTB_TOPO_B2B_DSD:
> + return NTB_PORT_SEC_DSD;
> + default:
> + break;
> + }
> +
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL(ntb_default_port_number);
> +
> +int ntb_default_peer_port_count(struct ntb_dev *ntb)
> +{
> + return NTB_DEF_PEER_CNT;
> +}
> +EXPORT_SYMBOL(ntb_default_peer_port_count);
> +
> +int ntb_default_peer_port_number(struct ntb_dev *ntb, int pidx)
> +{
> + if (pidx != NTB_DEF_PEER_IDX)
> + return -EINVAL;
> +
> + switch (ntb->topo) {
> + case NTB_TOPO_PRI:
> + case NTB_TOPO_B2B_USD:
> + return NTB_PORT_SEC_DSD;
> + case NTB_TOPO_SEC:
> + case NTB_TOPO_B2B_DSD:
> + return NTB_PORT_PRI_USD;
> + default:
> + break;
> + }
> +
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL(ntb_default_peer_port_number);
> +
> +int ntb_default_peer_port_idx(struct ntb_dev *ntb, int port)
> +{
> + int peer_port = ntb_default_peer_port_number(ntb, NTB_DEF_PEER_IDX);
> +
> + if (peer_port == -EINVAL || port != peer_port)
> + return -EINVAL;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(ntb_default_peer_port_idx);
> +
>  static int ntb_probe(struct device *dev)
>  {
>   struct ntb_dev *ntb;
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index 4eb8adb..10518b7 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -94,6 +94,9 @@ MODULE_PARM_DESC(use_dma, "Use DMA engine to perform large 
> data copy");
> 
>  static struct dentry *nt_debugfs_dir;
> 
> +/* Only two-ports NTB devices are supported */
> +#define PIDX NTB_DEF_PEER_IDX
> +
>  struct ntb_queue_entry {
>   /* ntb_queue list reference */
>   struct list_head entry;
> @@ -1083,6 +1086,9 @@ static int ntb_transport_probe(struct ntb_client *self, 
> struct
> ntb_dev *ndev)
>   dev_dbg(>dev,
>   "scratchpad is unsafe, proceed anyway...\n");
> 
> + if (ntb_peer_port_count(ndev) != NTB_DEF_PEER_CNT)
> + dev_warn(>dev, "Multi-port NTB devices unsupported\n");
> +
>   node = dev_to_node(>dev);
> 
>   nt = kzalloc_node(sizeof(*nt), GFP_KERNEL, node);
> diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
> index e75d4fd..c908b3a 100644
> --- a/drivers/ntb/test/ntb_perf.c
> +++ b/drivers/ntb/test/ntb_perf.c
> @@ -76,6 +76,7 @@
>  #define DMA_RETRIES  20
>  #define SZ_4G(1ULL << 32)
>  #define MAX_SEG_ORDER20 /* no larger than 1M for kmalloc 
> buffer */
> +#define PIDX NTB_DEF_PEER_IDX
> 
>  MODULE_LICENSE(DRIVER_LICENSE);
>  MODULE_VERSION(DRIVER_VERSION);
> @@ -764,6 +765,9 @@ static int perf_probe(struct ntb_client *client, struct 
> ntb_dev *ntb)
>   return -EIO;
>   }
> 
> + if (ntb_peer_port_count(ntb) != NTB_DEF_PEER_CNT)
> + dev_warn(>dev, "Multi-port NTB devices unsupported\n");
> +
>   node = dev_to_node(>dev);
> 
>   perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node);
> diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c
> index 4358611..12f8b40 100644
> --- a/drivers/ntb/test/ntb_pingpong.c
> +++ 

Re: [PATCH] mtd: fix typos in ooblayout comment blocks

2016-12-13 Thread Boris Brezillon
On Wed, 14 Dec 2016 09:31:01 +0900
Masahiro Yamada  wrote:

>  - "This functions return ..." -> "This function returns ..."
>  - "I you want ..." -> "If you want ..."
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Boris Brezillon 

> ---
> 
>  drivers/mtd/mtdcore.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index ca661ce..d64e61b 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1129,7 +1129,7 @@ EXPORT_SYMBOL_GPL(mtd_write_oob);
>   * @oobecc: OOB region struct filled with the appropriate ECC position
>   *   information
>   *
> - * This functions return ECC section information in the OOB area. I you want
> + * This function returns ECC section information in the OOB area. If you want
>   * to get all the ECC bytes information, then you should call
>   * mtd_ooblayout_ecc(mtd, section++, oobecc) until it returns -ERANGE.
>   *
> @@ -1161,7 +1161,7 @@ EXPORT_SYMBOL_GPL(mtd_ooblayout_ecc);
>   * @oobfree: OOB region struct filled with the appropriate free position
>   *information
>   *
> - * This functions return free bytes position in the OOB area. I you want
> + * This function returns free bytes position in the OOB area. If you want
>   * to get all the free bytes information, then you should call
>   * mtd_ooblayout_free(mtd, section++, oobfree) until it returns -ERANGE.
>   *
> @@ -1191,7 +1191,7 @@ EXPORT_SYMBOL_GPL(mtd_ooblayout_free);
>   * @iter: iterator function. Should be either mtd_ooblayout_free or
>   * mtd_ooblayout_ecc depending on the region type you're searching for
>   *
> - * This functions returns the section id and oobregion information of a
> + * This function returns the section id and oobregion information of a
>   * specific byte. For example, say you want to know where the 4th ECC byte is
>   * stored, you'll use:
>   *



Re: [PATCH] mtd: fix typos in ooblayout comment blocks

2016-12-13 Thread Boris Brezillon
On Wed, 14 Dec 2016 09:31:01 +0900
Masahiro Yamada  wrote:

>  - "This functions return ..." -> "This function returns ..."
>  - "I you want ..." -> "If you want ..."
> 
> Signed-off-by: Masahiro Yamada 

Acked-by: Boris Brezillon 

> ---
> 
>  drivers/mtd/mtdcore.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index ca661ce..d64e61b 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1129,7 +1129,7 @@ EXPORT_SYMBOL_GPL(mtd_write_oob);
>   * @oobecc: OOB region struct filled with the appropriate ECC position
>   *   information
>   *
> - * This functions return ECC section information in the OOB area. I you want
> + * This function returns ECC section information in the OOB area. If you want
>   * to get all the ECC bytes information, then you should call
>   * mtd_ooblayout_ecc(mtd, section++, oobecc) until it returns -ERANGE.
>   *
> @@ -1161,7 +1161,7 @@ EXPORT_SYMBOL_GPL(mtd_ooblayout_ecc);
>   * @oobfree: OOB region struct filled with the appropriate free position
>   *information
>   *
> - * This functions return free bytes position in the OOB area. I you want
> + * This function returns free bytes position in the OOB area. If you want
>   * to get all the free bytes information, then you should call
>   * mtd_ooblayout_free(mtd, section++, oobfree) until it returns -ERANGE.
>   *
> @@ -1191,7 +1191,7 @@ EXPORT_SYMBOL_GPL(mtd_ooblayout_free);
>   * @iter: iterator function. Should be either mtd_ooblayout_free or
>   * mtd_ooblayout_ecc depending on the region type you're searching for
>   *
> - * This functions returns the section id and oobregion information of a
> + * This function returns the section id and oobregion information of a
>   * specific byte. For example, say you want to know where the 4th ECC byte is
>   * stored, you'll use:
>   *



Re: [PATCH v7 1/2] usb: xhci: plat: Enable runtime PM

2016-12-13 Thread Robert Foss

Hey Baolin,

On 2016-12-12 12:21 AM, Baolin Wang wrote:

Hi Robert,

On 2 December 2016 at 05:46, Robert Foss  wrote:

Enable runtime PM for the xhci-plat device so that the parent device
may implement runtime PM.

Signed-off-by: Robert Foss 

Tested-by: Robert Foss 
---
 drivers/usb/host/xhci-plat.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9ed885..ba4efe74f537 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -246,6 +246,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (ret)
goto dealloc_usb2_hcd;

+   pm_runtime_set_active(>dev);
+   pm_runtime_enable(>dev);


You did not implement the runtime callbacks of xHCI device, then how
can the parent device control the resume/suspend of xHCI device by
runtime PM mechanism? Could you see my previous patch which implement
the runtime callbacks for xHCI device?
https://lkml.org/lkml/2016/11/28/25



Pardon my ignorance, but which exact functions need to be implemented?
Also, does the lkml link you provided contain an example implementation 
of those functions?



+
return 0;


@@ -274,6 +277,8 @@ static int xhci_plat_remove(struct platform_device *dev)
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct clk *clk = xhci->clk;

+   pm_runtime_disable(>dev);
+
usb_remove_hcd(xhci->shared_hcd);
usb_phy_shutdown(hcd->usb_phy);

@@ -292,6 +297,13 @@ static int xhci_plat_suspend(struct device *dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
+
+   ret = pm_runtime_get_sync(dev);
+   if (ret < 0) {
+   pm_runtime_put(dev);
+   return ret;
+   }

/*
 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
@@ -301,15 +313,28 @@ static int xhci_plat_suspend(struct device *dev)
 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
 * also applies to runtime suspend.
 */
-   return xhci_suspend(xhci, device_may_wakeup(dev));
+   ret = xhci_suspend(xhci, device_may_wakeup(dev));
+   pm_runtime_put(dev);
+
+   return ret;
 }

 static int xhci_plat_resume(struct device *dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;

-   return xhci_resume(xhci, 0);
+   ret = pm_runtime_get_sync(dev);
+   if (ret < 0) {
+   pm_runtime_put(dev);
+   return ret;
+   }
+
+   ret = xhci_resume(xhci, 0);
+   pm_runtime_put(dev);
+
+   return ret;
 }

 static const struct dev_pm_ops xhci_plat_pm_ops = {
--
2.11.0







Re: [PATCH v7 1/2] usb: xhci: plat: Enable runtime PM

2016-12-13 Thread Robert Foss

Hey Baolin,

On 2016-12-12 12:21 AM, Baolin Wang wrote:

Hi Robert,

On 2 December 2016 at 05:46, Robert Foss  wrote:

Enable runtime PM for the xhci-plat device so that the parent device
may implement runtime PM.

Signed-off-by: Robert Foss 

Tested-by: Robert Foss 
---
 drivers/usb/host/xhci-plat.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9ed885..ba4efe74f537 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -246,6 +246,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (ret)
goto dealloc_usb2_hcd;

+   pm_runtime_set_active(>dev);
+   pm_runtime_enable(>dev);


You did not implement the runtime callbacks of xHCI device, then how
can the parent device control the resume/suspend of xHCI device by
runtime PM mechanism? Could you see my previous patch which implement
the runtime callbacks for xHCI device?
https://lkml.org/lkml/2016/11/28/25



Pardon my ignorance, but which exact functions need to be implemented?
Also, does the lkml link you provided contain an example implementation 
of those functions?



+
return 0;


@@ -274,6 +277,8 @@ static int xhci_plat_remove(struct platform_device *dev)
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct clk *clk = xhci->clk;

+   pm_runtime_disable(>dev);
+
usb_remove_hcd(xhci->shared_hcd);
usb_phy_shutdown(hcd->usb_phy);

@@ -292,6 +297,13 @@ static int xhci_plat_suspend(struct device *dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
+
+   ret = pm_runtime_get_sync(dev);
+   if (ret < 0) {
+   pm_runtime_put(dev);
+   return ret;
+   }

/*
 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
@@ -301,15 +313,28 @@ static int xhci_plat_suspend(struct device *dev)
 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
 * also applies to runtime suspend.
 */
-   return xhci_suspend(xhci, device_may_wakeup(dev));
+   ret = xhci_suspend(xhci, device_may_wakeup(dev));
+   pm_runtime_put(dev);
+
+   return ret;
 }

 static int xhci_plat_resume(struct device *dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;

-   return xhci_resume(xhci, 0);
+   ret = pm_runtime_get_sync(dev);
+   if (ret < 0) {
+   pm_runtime_put(dev);
+   return ret;
+   }
+
+   ret = xhci_resume(xhci, 0);
+   pm_runtime_put(dev);
+
+   return ret;
 }

 static const struct dev_pm_ops xhci_plat_pm_ops = {
--
2.11.0







Re: [RFC PATCH v3] audit: use proper refcount locking on audit_sock

2016-12-13 Thread Cong Wang
On Tue, Dec 13, 2016 at 8:00 PM, Richard Guy Briggs  wrote:
> On 2016-12-13 16:19, Cong Wang wrote:
>> On Tue, Dec 13, 2016 at 7:03 AM, Richard Guy Briggs  wrote:
>> > @@ -1283,8 +1299,10 @@ static void __net_exit audit_net_exit(struct net 
>> > *net)
>> >  {
>> > struct audit_net *aunet = net_generic(net, audit_net_id);
>> > struct sock *sock = aunet->nlsk;
>> > +   mutex_lock(_cmd_mutex);
>> > if (sock == audit_sock)
>> > auditd_reset();
>> > +   mutex_unlock(_cmd_mutex);
>>
>> This still doesn't look correct to me, b/c here we release the audit_sock
>> refcnt twice:
>>
>> 1) inside audit_reset()
>
> The audit_reset() refcount decrement corresponds to a setting of
> audit_sock only if audit_sock is still non-NULL.
>

Hmm, thinking about it again, looks like the sock == audit_sock
and audit_sock != NULL checks can guarantee we are safe. So,

Reviewed-by: Cong Wang 


Re: [RFC PATCH v3] audit: use proper refcount locking on audit_sock

2016-12-13 Thread Cong Wang
On Tue, Dec 13, 2016 at 8:00 PM, Richard Guy Briggs  wrote:
> On 2016-12-13 16:19, Cong Wang wrote:
>> On Tue, Dec 13, 2016 at 7:03 AM, Richard Guy Briggs  wrote:
>> > @@ -1283,8 +1299,10 @@ static void __net_exit audit_net_exit(struct net 
>> > *net)
>> >  {
>> > struct audit_net *aunet = net_generic(net, audit_net_id);
>> > struct sock *sock = aunet->nlsk;
>> > +   mutex_lock(_cmd_mutex);
>> > if (sock == audit_sock)
>> > auditd_reset();
>> > +   mutex_unlock(_cmd_mutex);
>>
>> This still doesn't look correct to me, b/c here we release the audit_sock
>> refcnt twice:
>>
>> 1) inside audit_reset()
>
> The audit_reset() refcount decrement corresponds to a setting of
> audit_sock only if audit_sock is still non-NULL.
>

Hmm, thinking about it again, looks like the sock == audit_sock
and audit_sock != NULL checks can guarantee we are safe. So,

Reviewed-by: Cong Wang 


Re: [PATCH v4 1/4] powernv:idle: Add IDLE_STATE_ENTER_SEQ_NORET macro

2016-12-13 Thread Gautham R Shenoy
Hi Balbir,

On Tue, Dec 13, 2016 at 09:13:26PM +1100, Balbir Singh wrote:
> 
> 
> On 10/12/16 00:32, Gautham R. Shenoy wrote:
> > From: "Gautham R. Shenoy" 
> > diff --git a/arch/powerpc/include/asm/cpuidle.h 
> > b/arch/powerpc/include/asm/cpuidle.h
> > index 3919332..0a3255b 100644
> > --- a/arch/powerpc/include/asm/cpuidle.h
> > +++ b/arch/powerpc/include/asm/cpuidle.h
> > @@ -21,7 +21,7 @@
> >  
> >  /* Idle state entry routines */
> >  #ifdef CONFIG_PPC_P7_NAP
> > -#defineIDLE_STATE_ENTER_SEQ(IDLE_INST) \
> > +#define IDLE_STATE_ENTER_SEQ(IDLE_INST) \
> > /* Magic NAP/SLEEP/WINKLE mode enter sequence */\
> > std r0,0(r1);   \
> > ptesync;\
> > @@ -29,6 +29,9 @@
> >  1: cmpdcr0,r0,r0;  \
> > bne 1b; \
> > IDLE_INST;  \
> > +
> 
> Is the power saving magic sequence the same as before for power 9
> as well?

Yes, this is the same magic sequence for POWER9.

--
Thanks and Regards
gautham.



Re: [PATCH v4 1/4] powernv:idle: Add IDLE_STATE_ENTER_SEQ_NORET macro

2016-12-13 Thread Gautham R Shenoy
Hi Balbir,

On Tue, Dec 13, 2016 at 09:13:26PM +1100, Balbir Singh wrote:
> 
> 
> On 10/12/16 00:32, Gautham R. Shenoy wrote:
> > From: "Gautham R. Shenoy" 
> > diff --git a/arch/powerpc/include/asm/cpuidle.h 
> > b/arch/powerpc/include/asm/cpuidle.h
> > index 3919332..0a3255b 100644
> > --- a/arch/powerpc/include/asm/cpuidle.h
> > +++ b/arch/powerpc/include/asm/cpuidle.h
> > @@ -21,7 +21,7 @@
> >  
> >  /* Idle state entry routines */
> >  #ifdef CONFIG_PPC_P7_NAP
> > -#defineIDLE_STATE_ENTER_SEQ(IDLE_INST) \
> > +#define IDLE_STATE_ENTER_SEQ(IDLE_INST) \
> > /* Magic NAP/SLEEP/WINKLE mode enter sequence */\
> > std r0,0(r1);   \
> > ptesync;\
> > @@ -29,6 +29,9 @@
> >  1: cmpdcr0,r0,r0;  \
> > bne 1b; \
> > IDLE_INST;  \
> > +
> 
> Is the power saving magic sequence the same as before for power 9
> as well?

Yes, this is the same magic sequence for POWER9.

--
Thanks and Regards
gautham.



[GIT PULL] MD update for 4.10

2016-12-13 Thread Shaohua Li
Hi Linus,

Please pull MD changes for 4.10. This update includes:
- A raid5 writeback cache feature. The goal is to aggregate writes to make full
  stripe write and reduce read-modify-write. It's helpful for workload which
  does sequential write and follows fsync for example. This feature is
  experimental and off by default right now.
- FAILFAST support. This fails IOs to broken raid disks quickly, so can improve
  latency. It's mainly for DASD storage, but some patches help normal raid
  array too.
- Support bad block for raid array with external metadata
- AVX2 instruction support for raid6 parity calculation
- Normalize MD info output
- Add missing blktrace
- Other bug fixes

Thanks,
Shaohua

The following changes since commit b78b499a67c3f77aeb6cd0b54724bc38b141255d:

  Merge tag 'char-misc-4.10-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc (2016-12-13 
12:11:01 -0800)

are available in the git repository at:

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

for you to fetch changes up to 20737738d397dfadbca1ea50dcc00d7259f500cf:

  Merge branch 'md-next' into md-linus (2016-12-13 12:40:15 -0800)


Dan Carpenter (1):
  md/r5cache: enable IRQs on error path

Gayatri Kammela (1):
  lib/raid6: Add AVX2 optimized xor_syndrome functions

Guoqing Jiang (1):
  md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns 
-ENOMEM

JackieLiu (8):
  raid5-cache: restrict the use area of the log_offset variable
  md/raid5-cache: remove unnecessary function parameters
  md/raid5-cache: use ring add to prevent overflow
  md/raid5-cache: release the stripe_head at the appropriate location
  md/raid5-cache: remove the unnecessary next_cp_seq field from the r5l_log
  md/raid5-cache: do not need to set STRIPE_PREREAD_ACTIVE repeatedly
  md/raid5-cache: adjust the write position of the empty block if no data 
blocks
  md/raid5-cache: no recovery is required when create super-block

Konstantin Khlebnikov (1):
  md/raid5: limit request size according to implementation limits

NeilBrown (26):
  md: fix some issues with alloc_disk_sb()
  md: change all printk() to pr_err() or pr_warn() etc.
  md/bitmap: change all printk() to pr_*()
  md/linear: replace printk() with pr_*()
  md/multipath: replace printk() with pr_*()
  md/raid0: replace printk() with pr_*()
  md/raid1: change printk() to pr_*()
  md/raid10: change printk() to pr_*()
  md/raid5: change printk() to pr_*()
  md: perform async updates for metadata where possible.
  md/raid1: abort delayed writes when device fails.
  md/raid10: abort delayed writes when device fails.
  md/bitmap: Don't write bitmap while earlier writes might be in-flight
  md/raid1: fix: IO can block resync indefinitely
  md: define mddev flags, recovery flags and r1bio state bits using enums
  md: remove md_super_wait() call after bitmap_flush()
  md: add block tracing for bio_remapping
  md/bitmap: add blktrace event for writes to the bitmap
  md/raid1, raid10: add blktrace records when IO is delayed
  md/failfast: add failfast flag for md to be used by some personalities.
  md: Use REQ_FAILFAST_* on metadata writes where appropriate
  md/raid1: add failfast handling for reads.
  md/raid1: add failfast handling for writes.
  md/raid10: add failfast handling for reads.
  md/raid10: add failfast handling for writes.
  md: fix refcount problem on mddev when stopping array.

Shaohua Li (8):
  raid5-cache: fix lockdep warning
  md: add blktrace event for writes to superblock
  raid5-cache: suspend reclaim thread instead of shutdown
  md: stop write should stop journal reclaim
  md: takeover should clear unrelated bits
  md: MD_RECOVERY_NEEDED is set for mddev->recovery
  md: separate flags for superblock changes
  Merge branch 'md-next' into md-linus

Song Liu (14):
  md/r5cache: Check array size in r5l_init_log
  md/r5cache: move some code to raid5.h
  md/r5cache: State machine for raid5-cache write back mode
  md/r5cache: caching phase of r5cache
  md/r5cache: write-out phase and reclaim support
  md/r5cache: sysfs entry journal_mode
  md/r5cache: refactoring journal recovery code
  md/r5cache: r5cache recovery: part 1
  md/r5cache: r5cache recovery: part 2
  md/r5cache: handle FLUSH and FUA
  md/r5cache: handle alloc_page failure
  md/r5cache: run_no_space_stripes() when R5C_LOG_CRITICAL == 0
  md/raid5-cache: fix crc in rewrite_data_only_stripes()
  md/r5cache: after recovery, increase journal seq by 1

Tomasz Majchrzak (4):
  md: add bad block support for external metadata
  md: don't fail an array if there are unacknowledged bad blocks
  md: wake up personality thread after array state update
  raid5: revert commit 

[GIT PULL] MD update for 4.10

2016-12-13 Thread Shaohua Li
Hi Linus,

Please pull MD changes for 4.10. This update includes:
- A raid5 writeback cache feature. The goal is to aggregate writes to make full
  stripe write and reduce read-modify-write. It's helpful for workload which
  does sequential write and follows fsync for example. This feature is
  experimental and off by default right now.
- FAILFAST support. This fails IOs to broken raid disks quickly, so can improve
  latency. It's mainly for DASD storage, but some patches help normal raid
  array too.
- Support bad block for raid array with external metadata
- AVX2 instruction support for raid6 parity calculation
- Normalize MD info output
- Add missing blktrace
- Other bug fixes

Thanks,
Shaohua

The following changes since commit b78b499a67c3f77aeb6cd0b54724bc38b141255d:

  Merge tag 'char-misc-4.10-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc (2016-12-13 
12:11:01 -0800)

are available in the git repository at:

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

for you to fetch changes up to 20737738d397dfadbca1ea50dcc00d7259f500cf:

  Merge branch 'md-next' into md-linus (2016-12-13 12:40:15 -0800)


Dan Carpenter (1):
  md/r5cache: enable IRQs on error path

Gayatri Kammela (1):
  lib/raid6: Add AVX2 optimized xor_syndrome functions

Guoqing Jiang (1):
  md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns 
-ENOMEM

JackieLiu (8):
  raid5-cache: restrict the use area of the log_offset variable
  md/raid5-cache: remove unnecessary function parameters
  md/raid5-cache: use ring add to prevent overflow
  md/raid5-cache: release the stripe_head at the appropriate location
  md/raid5-cache: remove the unnecessary next_cp_seq field from the r5l_log
  md/raid5-cache: do not need to set STRIPE_PREREAD_ACTIVE repeatedly
  md/raid5-cache: adjust the write position of the empty block if no data 
blocks
  md/raid5-cache: no recovery is required when create super-block

Konstantin Khlebnikov (1):
  md/raid5: limit request size according to implementation limits

NeilBrown (26):
  md: fix some issues with alloc_disk_sb()
  md: change all printk() to pr_err() or pr_warn() etc.
  md/bitmap: change all printk() to pr_*()
  md/linear: replace printk() with pr_*()
  md/multipath: replace printk() with pr_*()
  md/raid0: replace printk() with pr_*()
  md/raid1: change printk() to pr_*()
  md/raid10: change printk() to pr_*()
  md/raid5: change printk() to pr_*()
  md: perform async updates for metadata where possible.
  md/raid1: abort delayed writes when device fails.
  md/raid10: abort delayed writes when device fails.
  md/bitmap: Don't write bitmap while earlier writes might be in-flight
  md/raid1: fix: IO can block resync indefinitely
  md: define mddev flags, recovery flags and r1bio state bits using enums
  md: remove md_super_wait() call after bitmap_flush()
  md: add block tracing for bio_remapping
  md/bitmap: add blktrace event for writes to the bitmap
  md/raid1, raid10: add blktrace records when IO is delayed
  md/failfast: add failfast flag for md to be used by some personalities.
  md: Use REQ_FAILFAST_* on metadata writes where appropriate
  md/raid1: add failfast handling for reads.
  md/raid1: add failfast handling for writes.
  md/raid10: add failfast handling for reads.
  md/raid10: add failfast handling for writes.
  md: fix refcount problem on mddev when stopping array.

Shaohua Li (8):
  raid5-cache: fix lockdep warning
  md: add blktrace event for writes to superblock
  raid5-cache: suspend reclaim thread instead of shutdown
  md: stop write should stop journal reclaim
  md: takeover should clear unrelated bits
  md: MD_RECOVERY_NEEDED is set for mddev->recovery
  md: separate flags for superblock changes
  Merge branch 'md-next' into md-linus

Song Liu (14):
  md/r5cache: Check array size in r5l_init_log
  md/r5cache: move some code to raid5.h
  md/r5cache: State machine for raid5-cache write back mode
  md/r5cache: caching phase of r5cache
  md/r5cache: write-out phase and reclaim support
  md/r5cache: sysfs entry journal_mode
  md/r5cache: refactoring journal recovery code
  md/r5cache: r5cache recovery: part 1
  md/r5cache: r5cache recovery: part 2
  md/r5cache: handle FLUSH and FUA
  md/r5cache: handle alloc_page failure
  md/r5cache: run_no_space_stripes() when R5C_LOG_CRITICAL == 0
  md/raid5-cache: fix crc in rewrite_data_only_stripes()
  md/r5cache: after recovery, increase journal seq by 1

Tomasz Majchrzak (4):
  md: add bad block support for external metadata
  md: don't fail an array if there are unacknowledged bad blocks
  md: wake up personality thread after array state update
  raid5: revert commit 

Re: [RFC PATCH v2] crypto: Add IV generation algorithms

2016-12-13 Thread Binoy Jayan
Hi Milan,

Thank you for the reply.

On 13 December 2016 at 15:31, Milan Broz  wrote:

> I really do not think the disk encryption key management should be moved
> outside of dm-crypt. We cannot then change key structure later easily.

Yes, I agree. but the key selection based on sector number restricts the
option of having a larger block size used for encryption.

>> + unsigned int key_size;
>> + unsigned int key_extra_size;
>> + unsigned int key_parts;  /* independent parts in key buffer */
>
> ^^^ these key sizes you probably mean by key management.

Yes, I mean splitting the keys into subkeys based on the keycount
parameter (as mentioned below) to the dm-crypt.

cipher[:keycount]-mode-iv:ivopts
aes:2-cbc-essiv:sha256

> It is based on way how the key is currently sent into kernel
> (one hexa string in ioctl that needs to be split) and have to be changed in 
> future.

-Binoy


Re: [RFC PATCH v2] crypto: Add IV generation algorithms

2016-12-13 Thread Binoy Jayan
Hi Milan,

Thank you for the reply.

On 13 December 2016 at 15:31, Milan Broz  wrote:

> I really do not think the disk encryption key management should be moved
> outside of dm-crypt. We cannot then change key structure later easily.

Yes, I agree. but the key selection based on sector number restricts the
option of having a larger block size used for encryption.

>> + unsigned int key_size;
>> + unsigned int key_extra_size;
>> + unsigned int key_parts;  /* independent parts in key buffer */
>
> ^^^ these key sizes you probably mean by key management.

Yes, I mean splitting the keys into subkeys based on the keycount
parameter (as mentioned below) to the dm-crypt.

cipher[:keycount]-mode-iv:ivopts
aes:2-cbc-essiv:sha256

> It is based on way how the key is currently sent into kernel
> (one hexa string in ioctl that needs to be split) and have to be changed in 
> future.

-Binoy


Re: [PATCH v3 1/2] ARM: ep93xx: Register ts73xx-fpga manager driver for TS-7300

2016-12-13 Thread Moritz Fischer
Hi Florian,

On Tue, Dec 13, 2016 at 6:35 PM, Florian Fainelli  wrote:
> Register the TS-7300 FPGA manager device drivers which allows us to load
> bitstreams into the on-board Altera Cyclone II FPGA.
>
> Signed-off-by: Florian Fainelli 
> ---
>  arch/arm/mach-ep93xx/ts72xx.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
> index 3b39ea353d30..acf72ea670ef 100644
> --- a/arch/arm/mach-ep93xx/ts72xx.c
> +++ b/arch/arm/mach-ep93xx/ts72xx.c
> @@ -230,6 +230,28 @@ static struct ep93xx_eth_data __initdata ts72xx_eth_data 
> = {
> .phy_id = 1,
>  };
>
> +#if IS_ENABLED(CONFIG_FPGA_MGR_TS73XX)
> +
> +/* Relative to EP93XX_CS1_PHYS_BASE */
> +#define TS73XX_FPGA_LOADER_BASE0x03c0
> +
> +static struct resource ts73xx_fpga_resources[] = {
> +   {
> +   .start  = EP93XX_CS1_PHYS_BASE + TS73XX_FPGA_LOADER_BASE,
> +   .end= EP93XX_CS1_PHYS_BASE + TS73XX_FPGA_LOADER_BASE + 1,
> +   .flags  = IORESOURCE_MEM,
> +   },
> +};
> +
> +static struct platform_device ts73xx_fpga_device = {
> +   .name   = "ts73xx-fpga-mgr",
> +   .id = -1,
> +   .resource = ts73xx_fpga_resources,
> +   .num_resources = ARRAY_SIZE(ts73xx_fpga_resources),
> +};
> +
> +#endif
> +
>  static void __init ts72xx_init_machine(void)
>  {
> ep93xx_init_devices();
> @@ -238,6 +260,10 @@ static void __init ts72xx_init_machine(void)
> platform_device_register(_wdt_device);
>
> ep93xx_register_eth(_eth_data, 1);
> +#if IS_ENABLED(CONFIG_FPGA_MGR_TS73XX)
> +   if (board_is_ts7300())
> +   platform_device_register(_fpga_device);
> +#endif
>  }
>
>  MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
> --
> 2.9.3
>

I think this is backwards, shouldn't this be your [PATCH 2/2]?
Otherwise you're using
the driver before you added it.

Thanks,

Moritz


Re: [PATCH v3 1/2] ARM: ep93xx: Register ts73xx-fpga manager driver for TS-7300

2016-12-13 Thread Moritz Fischer
Hi Florian,

On Tue, Dec 13, 2016 at 6:35 PM, Florian Fainelli  wrote:
> Register the TS-7300 FPGA manager device drivers which allows us to load
> bitstreams into the on-board Altera Cyclone II FPGA.
>
> Signed-off-by: Florian Fainelli 
> ---
>  arch/arm/mach-ep93xx/ts72xx.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
> index 3b39ea353d30..acf72ea670ef 100644
> --- a/arch/arm/mach-ep93xx/ts72xx.c
> +++ b/arch/arm/mach-ep93xx/ts72xx.c
> @@ -230,6 +230,28 @@ static struct ep93xx_eth_data __initdata ts72xx_eth_data 
> = {
> .phy_id = 1,
>  };
>
> +#if IS_ENABLED(CONFIG_FPGA_MGR_TS73XX)
> +
> +/* Relative to EP93XX_CS1_PHYS_BASE */
> +#define TS73XX_FPGA_LOADER_BASE0x03c0
> +
> +static struct resource ts73xx_fpga_resources[] = {
> +   {
> +   .start  = EP93XX_CS1_PHYS_BASE + TS73XX_FPGA_LOADER_BASE,
> +   .end= EP93XX_CS1_PHYS_BASE + TS73XX_FPGA_LOADER_BASE + 1,
> +   .flags  = IORESOURCE_MEM,
> +   },
> +};
> +
> +static struct platform_device ts73xx_fpga_device = {
> +   .name   = "ts73xx-fpga-mgr",
> +   .id = -1,
> +   .resource = ts73xx_fpga_resources,
> +   .num_resources = ARRAY_SIZE(ts73xx_fpga_resources),
> +};
> +
> +#endif
> +
>  static void __init ts72xx_init_machine(void)
>  {
> ep93xx_init_devices();
> @@ -238,6 +260,10 @@ static void __init ts72xx_init_machine(void)
> platform_device_register(_wdt_device);
>
> ep93xx_register_eth(_eth_data, 1);
> +#if IS_ENABLED(CONFIG_FPGA_MGR_TS73XX)
> +   if (board_is_ts7300())
> +   platform_device_register(_fpga_device);
> +#endif
>  }
>
>  MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
> --
> 2.9.3
>

I think this is backwards, shouldn't this be your [PATCH 2/2]?
Otherwise you're using
the driver before you added it.

Thanks,

Moritz


Re: [RESEND PATCH v4 1/2] sysctl: introduce new proc handler proc_dobool

2016-12-13 Thread kbuild test robot
Hi Jia,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.9 next-20161214]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jia-He/sysctl-introduce-new-proc-handler-proc_dobool/20161214-112656
config: x86_64-randconfig-n0-12141159 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> kernel/built-in.o:(___ksymtab+proc_dobool+0x0): undefined reference to 
>> `proc_dobool'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [RESEND PATCH v4 1/2] sysctl: introduce new proc handler proc_dobool

2016-12-13 Thread kbuild test robot
Hi Jia,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.9 next-20161214]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jia-He/sysctl-introduce-new-proc-handler-proc_dobool/20161214-112656
config: x86_64-randconfig-n0-12141159 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> kernel/built-in.o:(___ksymtab+proc_dobool+0x0): undefined reference to 
>> `proc_dobool'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] doc: add note on usleep_range range

2016-12-13 Thread Joe Perches
On Wed, 2016-12-14 at 00:37 +, Nicholas Mc Guire wrote:
> On Tue, Dec 13, 2016 at 04:27:32PM -0800, Joe Perches wrote:
> > a, On Tue, 2016-12-13 at 09:19 +, Nicholas Mc Guire wrote:
> > > On Tue, Dec 13, 2016 at 11:10:50AM +0200, Jani Nikula wrote:
> > > > On Tue, 13 Dec 2016, Nicholas Mc Guire  wrote:
> > > > > useleep_range() with a delta of 0 makes no sense and only prevents the
> > > > > timer subsystem from optimizing interrupts. As any user of 
> > > > > usleep_range()
> > > > > is in non-atomic context the timer jitter is in the range of 10s of 
> > > > > microseconds anyway.
> > > > > 
> > > > > This adds a note making it clear that a range of 0 is a bad idea.
> > > > 
> > > > So I don't really have anything to do with the timer subsystem, I'm just
> > > > their "consumer", so take this with a grain of salt.
> > > > 
> > > > Documentation is good, but I don't think this will be enough.
> > > > 
> > > > I think the only thing that will work is to detect and complain about
> > > > things like this automatically. Some ideas:
> > > > 
> > > > * WARN_ON(min == max) or WARN_ON_ONCE(min == max) in usleep_range()
> > > >   might be drastic, but it would get the job done eventually.
> > > > 
> > > > * If you want to avoid the runtime overhead (and complaints about the
> > > >   backtraces), you could wrap usleep_range() in a macro that does
> > > >   BUILD_BUG_ON(min == max) if the parameters are build time constants
> > > >   (they usually are). But you'd have to fix all the problem cases first.
> > > > 
> > > > * You could try (to persuade Julia or Dan) to come up with a
> > > >   cocci/smatch check for usleep_range() calls where min == max, so we
> > > >   could get bug reports for this. This probably works on expressions, so
> > > >   this would catch also cases where the parameters aren't built timea,
> > > >   constants.
> > 
> > You could also add a macro for usleep_range like
> > 
> > #define usleep_range(a, b) \
> > ({ \
> > if (__builtin_constant_p(a) && __builtin_constant_p(b)) { \
> > if (a == b) \
> > __compiletime_warning("Better to use usleep_range with 
> > different values"); \
> > else if (a > b) \
> > __compiletime_error("usleep_range uses smaller value 
> > first"); \
> > } \
> > usleep_range(a, b); \
> > })
> > 
> 
> thanks for that "template" 
>  
> > and add parentheses around the actual function
> > definition for usleep_range in kernel/time/timer.c
> > so the macro works and these messages get emitted
> > at compile-time.
> > 
> 
> while compiletime warnings are a way to go I think that an
> external tool is more effective than anoying eveyone during
> build

I don't.

Annoying people at build-time is probably _the single most_
effective way to get source code defects fixed.



Re: [PATCH] doc: add note on usleep_range range

2016-12-13 Thread Joe Perches
On Wed, 2016-12-14 at 00:37 +, Nicholas Mc Guire wrote:
> On Tue, Dec 13, 2016 at 04:27:32PM -0800, Joe Perches wrote:
> > a, On Tue, 2016-12-13 at 09:19 +, Nicholas Mc Guire wrote:
> > > On Tue, Dec 13, 2016 at 11:10:50AM +0200, Jani Nikula wrote:
> > > > On Tue, 13 Dec 2016, Nicholas Mc Guire  wrote:
> > > > > useleep_range() with a delta of 0 makes no sense and only prevents the
> > > > > timer subsystem from optimizing interrupts. As any user of 
> > > > > usleep_range()
> > > > > is in non-atomic context the timer jitter is in the range of 10s of 
> > > > > microseconds anyway.
> > > > > 
> > > > > This adds a note making it clear that a range of 0 is a bad idea.
> > > > 
> > > > So I don't really have anything to do with the timer subsystem, I'm just
> > > > their "consumer", so take this with a grain of salt.
> > > > 
> > > > Documentation is good, but I don't think this will be enough.
> > > > 
> > > > I think the only thing that will work is to detect and complain about
> > > > things like this automatically. Some ideas:
> > > > 
> > > > * WARN_ON(min == max) or WARN_ON_ONCE(min == max) in usleep_range()
> > > >   might be drastic, but it would get the job done eventually.
> > > > 
> > > > * If you want to avoid the runtime overhead (and complaints about the
> > > >   backtraces), you could wrap usleep_range() in a macro that does
> > > >   BUILD_BUG_ON(min == max) if the parameters are build time constants
> > > >   (they usually are). But you'd have to fix all the problem cases first.
> > > > 
> > > > * You could try (to persuade Julia or Dan) to come up with a
> > > >   cocci/smatch check for usleep_range() calls where min == max, so we
> > > >   could get bug reports for this. This probably works on expressions, so
> > > >   this would catch also cases where the parameters aren't built timea,
> > > >   constants.
> > 
> > You could also add a macro for usleep_range like
> > 
> > #define usleep_range(a, b) \
> > ({ \
> > if (__builtin_constant_p(a) && __builtin_constant_p(b)) { \
> > if (a == b) \
> > __compiletime_warning("Better to use usleep_range with 
> > different values"); \
> > else if (a > b) \
> > __compiletime_error("usleep_range uses smaller value 
> > first"); \
> > } \
> > usleep_range(a, b); \
> > })
> > 
> 
> thanks for that "template" 
>  
> > and add parentheses around the actual function
> > definition for usleep_range in kernel/time/timer.c
> > so the macro works and these messages get emitted
> > at compile-time.
> > 
> 
> while compiletime warnings are a way to go I think that an
> external tool is more effective than anoying eveyone during
> build

I don't.

Annoying people at build-time is probably _the single most_
effective way to get source code defects fixed.



Re: [PATCH v3 2/2] FPGA: Add TS-7300 FPGA manager

2016-12-13 Thread Moritz Fischer
Hi Florian,

On Tue, Dec 13, 2016 at 6:35 PM, Florian Fainelli  wrote:
> Add support for loading bitstreams on the Altera Cyclone II FPGA
> populated on the TS-7300 board. This is done through the configuration
> and data registers offered through a memory interface between the EP93xx
> SoC and the FPGA via an intermediate CPLD device.
>
> The EP93xx SoC on the TS-7300 does not have direct means of configuring
> the on-board FPGA other than by using the special memory mapped
> interface to the CPLD. No other entity on the system can control the
> FPGA bitstream.
>
> Signed-off-by: Florian Fainelli 
> ---
>  drivers/fpga/Kconfig   |   7 ++
>  drivers/fpga/Makefile  |   1 +
>  drivers/fpga/ts73xx-fpga.c | 163 
> +
>  3 files changed, 171 insertions(+)
>  create mode 100644 drivers/fpga/ts73xx-fpga.c
>
> diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> index ce861a2853a4..d9cbef60db80 100644
> --- a/drivers/fpga/Kconfig
> +++ b/drivers/fpga/Kconfig
> @@ -33,6 +33,13 @@ config FPGA_MGR_SOCFPGA_A10
> help
>   FPGA manager driver support for Altera Arria10 SoCFPGA.
>
> +config FPGA_MGR_TS73XX
> +   tristate "Technologic Systems TS-73xx SBC FPGA Manager"
> +   depends on ARCH_EP93XX && MACH_TS72XX
> +   help
> + FPGA manager driver support for the Altera Cyclone II FPGA
> + present on the TS-73xx SBC boards.
> +
>  config FPGA_MGR_ZYNQ_FPGA
> tristate "Xilinx Zynq FPGA"
> depends on ARCH_ZYNQ || COMPILE_TEST
> diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
> index 8df07bcf42a6..a1160169e6d9 100644
> --- a/drivers/fpga/Makefile
> +++ b/drivers/fpga/Makefile
> @@ -8,6 +8,7 @@ obj-$(CONFIG_FPGA)  += fpga-mgr.o
>  # FPGA Manager Drivers
>  obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o
>  obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o
> +obj-$(CONFIG_FPGA_MGR_TS73XX)  += ts73xx-fpga.o
>  obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA)   += zynq-fpga.o
>
>  # FPGA Bridge Drivers
> diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
> new file mode 100644
> index ..38d78d8c6b1e
> --- /dev/null
> +++ b/drivers/fpga/ts73xx-fpga.c
> @@ -0,0 +1,163 @@
> +/*
> + * Technologic Systems TS-73xx SBC FPGA loader
> + *
> + * Copyright (C) 2016 Florian Fainelli 
> + *
> + * FPGA Manager Driver for the on-board Altera Cyclone II FPGA found on
> + * TS-7300, heavily based on load_fpga.c in their vendor tree.
> + *
> + * 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; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define TS73XX_FPGA_DATA_REG   0
> +#define TS73XX_FPGA_CONFIG_REG 1
> +
> +#define TS73XX_FPGA_WRITE_DONE 0x1
> +#define TS73XX_FPGA_WRITE_DONE_TIMEOUT 1000/* us */
> +#define TS73XX_FPGA_RESET  0x2
> +#define TS73XX_FPGA_RESET_LOW_DELAY30  /* us */
> +#define TS73XX_FPGA_RESET_HIGH_DELAY   80  /* us */
> +#define TS73XX_FPGA_LOAD_OK0x4
> +#define TS73XX_FPGA_CONFIG_LOAD0x8
> +
> +struct ts73xx_fpga_priv {
> +   void __iomem*io_base;
> +   struct device   *dev;
> +};
> +
> +static enum fpga_mgr_states ts73xx_fpga_state(struct fpga_manager *mgr)
> +{
> +   return FPGA_MGR_STATE_UNKNOWN;
> +}
> +
> +static int ts73xx_fpga_write_init(struct fpga_manager *mgr,
> + struct fpga_image_info *info,
> + const char *buf, size_t count)
> +{
> +   struct ts73xx_fpga_priv *priv = mgr->priv;
> +
> +   /* Reset the FPGA */
> +   writeb(0, priv->io_base + TS73XX_FPGA_CONFIG_REG);
> +   udelay(TS73XX_FPGA_RESET_LOW_DELAY);
> +   writeb(TS73XX_FPGA_RESET, priv->io_base + TS73XX_FPGA_CONFIG_REG);
> +   udelay(TS73XX_FPGA_RESET_HIGH_DELAY);
> +
> +   return 0;
> +}
> +
> +static int ts73xx_fpga_write(struct fpga_manager *mgr, const char *buf,
> +size_t count)
> +{
> +   struct ts73xx_fpga_priv *priv = mgr->priv;
> +   size_t i = 0;
> +   int ret;
> +   u8 reg;
> +
> +   while (count--) {
> +   ret = readb_poll_timeout(priv->io_base + 
> TS73XX_FPGA_CONFIG_REG,
> +reg, !(reg & TS73XX_FPGA_WRITE_DONE),
> +1, TS73XX_FPGA_WRITE_DONE_TIMEOUT);
> +   if (ret < 0)
> + 

Re: [PATCH v3 2/2] FPGA: Add TS-7300 FPGA manager

2016-12-13 Thread Moritz Fischer
Hi Florian,

On Tue, Dec 13, 2016 at 6:35 PM, Florian Fainelli  wrote:
> Add support for loading bitstreams on the Altera Cyclone II FPGA
> populated on the TS-7300 board. This is done through the configuration
> and data registers offered through a memory interface between the EP93xx
> SoC and the FPGA via an intermediate CPLD device.
>
> The EP93xx SoC on the TS-7300 does not have direct means of configuring
> the on-board FPGA other than by using the special memory mapped
> interface to the CPLD. No other entity on the system can control the
> FPGA bitstream.
>
> Signed-off-by: Florian Fainelli 
> ---
>  drivers/fpga/Kconfig   |   7 ++
>  drivers/fpga/Makefile  |   1 +
>  drivers/fpga/ts73xx-fpga.c | 163 
> +
>  3 files changed, 171 insertions(+)
>  create mode 100644 drivers/fpga/ts73xx-fpga.c
>
> diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> index ce861a2853a4..d9cbef60db80 100644
> --- a/drivers/fpga/Kconfig
> +++ b/drivers/fpga/Kconfig
> @@ -33,6 +33,13 @@ config FPGA_MGR_SOCFPGA_A10
> help
>   FPGA manager driver support for Altera Arria10 SoCFPGA.
>
> +config FPGA_MGR_TS73XX
> +   tristate "Technologic Systems TS-73xx SBC FPGA Manager"
> +   depends on ARCH_EP93XX && MACH_TS72XX
> +   help
> + FPGA manager driver support for the Altera Cyclone II FPGA
> + present on the TS-73xx SBC boards.
> +
>  config FPGA_MGR_ZYNQ_FPGA
> tristate "Xilinx Zynq FPGA"
> depends on ARCH_ZYNQ || COMPILE_TEST
> diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
> index 8df07bcf42a6..a1160169e6d9 100644
> --- a/drivers/fpga/Makefile
> +++ b/drivers/fpga/Makefile
> @@ -8,6 +8,7 @@ obj-$(CONFIG_FPGA)  += fpga-mgr.o
>  # FPGA Manager Drivers
>  obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o
>  obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o
> +obj-$(CONFIG_FPGA_MGR_TS73XX)  += ts73xx-fpga.o
>  obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA)   += zynq-fpga.o
>
>  # FPGA Bridge Drivers
> diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
> new file mode 100644
> index ..38d78d8c6b1e
> --- /dev/null
> +++ b/drivers/fpga/ts73xx-fpga.c
> @@ -0,0 +1,163 @@
> +/*
> + * Technologic Systems TS-73xx SBC FPGA loader
> + *
> + * Copyright (C) 2016 Florian Fainelli 
> + *
> + * FPGA Manager Driver for the on-board Altera Cyclone II FPGA found on
> + * TS-7300, heavily based on load_fpga.c in their vendor tree.
> + *
> + * 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; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define TS73XX_FPGA_DATA_REG   0
> +#define TS73XX_FPGA_CONFIG_REG 1
> +
> +#define TS73XX_FPGA_WRITE_DONE 0x1
> +#define TS73XX_FPGA_WRITE_DONE_TIMEOUT 1000/* us */
> +#define TS73XX_FPGA_RESET  0x2
> +#define TS73XX_FPGA_RESET_LOW_DELAY30  /* us */
> +#define TS73XX_FPGA_RESET_HIGH_DELAY   80  /* us */
> +#define TS73XX_FPGA_LOAD_OK0x4
> +#define TS73XX_FPGA_CONFIG_LOAD0x8
> +
> +struct ts73xx_fpga_priv {
> +   void __iomem*io_base;
> +   struct device   *dev;
> +};
> +
> +static enum fpga_mgr_states ts73xx_fpga_state(struct fpga_manager *mgr)
> +{
> +   return FPGA_MGR_STATE_UNKNOWN;
> +}
> +
> +static int ts73xx_fpga_write_init(struct fpga_manager *mgr,
> + struct fpga_image_info *info,
> + const char *buf, size_t count)
> +{
> +   struct ts73xx_fpga_priv *priv = mgr->priv;
> +
> +   /* Reset the FPGA */
> +   writeb(0, priv->io_base + TS73XX_FPGA_CONFIG_REG);
> +   udelay(TS73XX_FPGA_RESET_LOW_DELAY);
> +   writeb(TS73XX_FPGA_RESET, priv->io_base + TS73XX_FPGA_CONFIG_REG);
> +   udelay(TS73XX_FPGA_RESET_HIGH_DELAY);
> +
> +   return 0;
> +}
> +
> +static int ts73xx_fpga_write(struct fpga_manager *mgr, const char *buf,
> +size_t count)
> +{
> +   struct ts73xx_fpga_priv *priv = mgr->priv;
> +   size_t i = 0;
> +   int ret;
> +   u8 reg;
> +
> +   while (count--) {
> +   ret = readb_poll_timeout(priv->io_base + 
> TS73XX_FPGA_CONFIG_REG,
> +reg, !(reg & TS73XX_FPGA_WRITE_DONE),
> +1, TS73XX_FPGA_WRITE_DONE_TIMEOUT);
> +   if (ret < 0)
> +   return ret;
> +
> +   writeb(buf[i], priv->io_base 

[PATCH 1/2] drm/panel: Add support for S6E3HA2 panel driver on TM2 board

2016-12-13 Thread Hoegeun Kwon
This patch add support for MIPI-DSI based S6E3HA2 AMOLED panel
driver. This panel has 1440x2560 resolution in 5.7-inch physical
panel in the TM2 device.

Signed-off-by: Donghwa Lee 
Signed-off-by: Hyungwon Hwang 
Signed-off-by: Hoegeun Kwon 
---
 .../bindings/display/panel/samsung,s6e3ha2.txt |  52 ++
 drivers/gpu/drm/panel/Kconfig  |   6 +
 drivers/gpu/drm/panel/Makefile |   1 +
 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c  | 756 +
 4 files changed, 815 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c

diff --git 
a/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt 
b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
new file mode 100644
index 000..1f41f24
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
@@ -0,0 +1,52 @@
+Samsung S6E3HA2 5.7" 1440x2560 AMOLED panel
+
+Required properties:
+  - compatible: "samsung,s6e3ha2"
+  - reg: the virtual channel number of a DSI peripheral
+  - vdd3-supply: core voltage supply
+  - vci-supply: voltage supply for analog circuits
+  - reset-gpios: a GPIO spec for the reset pin
+  - enable-gpios: a GPIO spec for the panel enable pin
+  - te-gpios: a GPIO spec for the tearing effect synchronization signal gpio 
pin
+
+Optional properties:
+  - display-timings: timings for the connected panel as described by [1]
+
+The device node can contain one 'port' child node with one child
+'endpoint' node, according to the bindings defined in [2]. This
+node should describe panel's video bus.
+
+[1]: Documentation/devicetree/bindings/display/panel/display-timing.txt
+[2]: Documentation/devicetree/bindings/media/video-interfaces.txt
+
+Example:
+
+   panel@0 {
+   compatible = "samsung,s6e3ha2";
+   reg = <0>;
+   vdd3-supply = <_reg>;
+   vci-supply = <_reg>;
+   reset-gpios = < 0 GPIO_ACTIVE_HIGH>;
+   enable-gpios = < 5 GPIO_ACTIVE_HIGH>;
+   te-gpios = < 3 GPIO_ACTIVE_HIGH>;
+
+   display-timings {
+   timing-0 {
+   clock-frequency = <0>;
+   hactive = <1440>;
+   vactive = <2560>;
+   hfront-porch = <1>;
+   hback-porch = <1>;
+   hsync-len = <1>;
+   vfront-porch = <1>;
+   vback-porch = <15>;
+   vsync-len = <1>;
+   };
+   };
+
+   port {
+   dsi_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 62aba97..e1a2fcd 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -58,6 +58,12 @@ config DRM_PANEL_SAMSUNG_S6E8AA0
select DRM_MIPI_DSI
select VIDEOMODE_HELPERS
 
+config DRM_PANEL_SAMSUNG_S6E3HA2
+   tristate "Samsung S6E3HA2 DSI video mode panel"
+   depends on OF
+   select DRM_MIPI_DSI
+   select VIDEOMODE_HELPERS
+
 config DRM_PANEL_SHARP_LQ101R1SX01
tristate "Sharp LQ101R1SX01 panel"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index a5c7ec0..993699b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -4,5 +4,6 @@ obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
 obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += 
panel-panasonic-vvx10f034n00.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
+obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c 
b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
new file mode 100644
index 000..a6ad63b
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
@@ -0,0 +1,756 @@
+/*
+ * MIPI-DSI based s6e3ha2 AMOLED 5.7 inch panel driver.
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Donghwa Lee 
+ * Hyungwon Hwang 
+ * Hoegeun Kwon 
+ *
+ * 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.
+*/
+
+#include 
+#include 
+#include 
+#include 

[PATCH 2/2] arm64: dts: exynos: Add support for S6E3HA2 panel device on TM2 board

2016-12-13 Thread Hoegeun Kwon
From: Hyungwon Hwang 

This patch add the panel device tree node for S6E3HA2 display
controller to TM2 dts.

Signed-off-by: Hyungwon Hwang 
Signed-off-by: Andrzej Hajda 
Signed-off-by: Chanwoo Choi 
Signed-off-by: Hoegeun Kwon 
---
 arch/arm64/boot/dts/exynos/exynos5433-tm2.dts | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts 
b/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts
index db879f4..4ad2332 100644
--- a/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts
+++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts
@@ -252,11 +252,44 @@
reg = <1>;
 
dsi_out: endpoint {
+   remote-endpoint = <_in>;
samsung,burst-clock-frequency = <51200>;
samsung,esc-clock-frequency = <1600>;
};
};
};
+
+   panel@0 {
+   compatible = "samsung,s6e3ha2";
+   reg = <0>;
+   vdd3-supply = <_reg>;
+   vci-supply = <_reg>;
+   reset-gpios = < 0 GPIO_ACTIVE_HIGH>;
+   enable-gpios = < 5 GPIO_ACTIVE_HIGH>;
+   te-gpios = < 3 GPIO_ACTIVE_HIGH>;
+   power-on-delay = <120>;
+   reset-delay = <5>;
+
+   display-timings {
+   timing-0 {
+   clock-frequency = <1487>;
+   hactive = <1440>;
+   vactive = <2560>;
+   hfront-porch = <1>;
+   hback-porch = <1>;
+   hsync-len = <1>;
+   vfront-porch = <1>;
+   vback-porch = <15>;
+   vsync-len = <1>;
+   };
+   };
+
+   port {
+   dsi_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
 };
 
 _0 {
-- 
1.9.1



[PATCH 0/2] Add support for the S6E3HA2 panel on TM2 board

2016-12-13 Thread Hoegeun Kwon
Purpose of this patch is add support for S6E3HA2 AMOLED panel on
the TM2 board. The first patch adds support for S6E3HA2 panel
device tree document and driver, the second patch add support for
S6E3HA2 panel device tree.

Hoegeun Kwon (1):
  drm/panel: Add support for S6E3HA2 panel driver on TM2 board

Hyungwon Hwang (1):
  arm64: dts: exynos: Add support for S6E3HA2 panel device on TM2 board

 .../bindings/display/panel/samsung,s6e3ha2.txt |  52 ++
 arch/arm64/boot/dts/exynos/exynos5433-tm2.dts  |  33 +
 drivers/gpu/drm/panel/Kconfig  |   6 +
 drivers/gpu/drm/panel/Makefile |   1 +
 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c  | 756 +
 5 files changed, 848 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c

-- 
1.9.1



[PATCH 1/2] drm/panel: Add support for S6E3HA2 panel driver on TM2 board

2016-12-13 Thread Hoegeun Kwon
This patch add support for MIPI-DSI based S6E3HA2 AMOLED panel
driver. This panel has 1440x2560 resolution in 5.7-inch physical
panel in the TM2 device.

Signed-off-by: Donghwa Lee 
Signed-off-by: Hyungwon Hwang 
Signed-off-by: Hoegeun Kwon 
---
 .../bindings/display/panel/samsung,s6e3ha2.txt |  52 ++
 drivers/gpu/drm/panel/Kconfig  |   6 +
 drivers/gpu/drm/panel/Makefile |   1 +
 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c  | 756 +
 4 files changed, 815 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c

diff --git 
a/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt 
b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
new file mode 100644
index 000..1f41f24
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
@@ -0,0 +1,52 @@
+Samsung S6E3HA2 5.7" 1440x2560 AMOLED panel
+
+Required properties:
+  - compatible: "samsung,s6e3ha2"
+  - reg: the virtual channel number of a DSI peripheral
+  - vdd3-supply: core voltage supply
+  - vci-supply: voltage supply for analog circuits
+  - reset-gpios: a GPIO spec for the reset pin
+  - enable-gpios: a GPIO spec for the panel enable pin
+  - te-gpios: a GPIO spec for the tearing effect synchronization signal gpio 
pin
+
+Optional properties:
+  - display-timings: timings for the connected panel as described by [1]
+
+The device node can contain one 'port' child node with one child
+'endpoint' node, according to the bindings defined in [2]. This
+node should describe panel's video bus.
+
+[1]: Documentation/devicetree/bindings/display/panel/display-timing.txt
+[2]: Documentation/devicetree/bindings/media/video-interfaces.txt
+
+Example:
+
+   panel@0 {
+   compatible = "samsung,s6e3ha2";
+   reg = <0>;
+   vdd3-supply = <_reg>;
+   vci-supply = <_reg>;
+   reset-gpios = < 0 GPIO_ACTIVE_HIGH>;
+   enable-gpios = < 5 GPIO_ACTIVE_HIGH>;
+   te-gpios = < 3 GPIO_ACTIVE_HIGH>;
+
+   display-timings {
+   timing-0 {
+   clock-frequency = <0>;
+   hactive = <1440>;
+   vactive = <2560>;
+   hfront-porch = <1>;
+   hback-porch = <1>;
+   hsync-len = <1>;
+   vfront-porch = <1>;
+   vback-porch = <15>;
+   vsync-len = <1>;
+   };
+   };
+
+   port {
+   dsi_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 62aba97..e1a2fcd 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -58,6 +58,12 @@ config DRM_PANEL_SAMSUNG_S6E8AA0
select DRM_MIPI_DSI
select VIDEOMODE_HELPERS
 
+config DRM_PANEL_SAMSUNG_S6E3HA2
+   tristate "Samsung S6E3HA2 DSI video mode panel"
+   depends on OF
+   select DRM_MIPI_DSI
+   select VIDEOMODE_HELPERS
+
 config DRM_PANEL_SHARP_LQ101R1SX01
tristate "Sharp LQ101R1SX01 panel"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index a5c7ec0..993699b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -4,5 +4,6 @@ obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
 obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += 
panel-panasonic-vvx10f034n00.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
+obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c 
b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
new file mode 100644
index 000..a6ad63b
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
@@ -0,0 +1,756 @@
+/*
+ * MIPI-DSI based s6e3ha2 AMOLED 5.7 inch panel driver.
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Donghwa Lee 
+ * Hyungwon Hwang 
+ * Hoegeun Kwon 
+ *
+ * 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.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define S6E3HA2_MIN_BRIGHTNESS 0
+#define S6E3HA2_MAX_BRIGHTNESS 100

[PATCH 2/2] arm64: dts: exynos: Add support for S6E3HA2 panel device on TM2 board

2016-12-13 Thread Hoegeun Kwon
From: Hyungwon Hwang 

This patch add the panel device tree node for S6E3HA2 display
controller to TM2 dts.

Signed-off-by: Hyungwon Hwang 
Signed-off-by: Andrzej Hajda 
Signed-off-by: Chanwoo Choi 
Signed-off-by: Hoegeun Kwon 
---
 arch/arm64/boot/dts/exynos/exynos5433-tm2.dts | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts 
b/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts
index db879f4..4ad2332 100644
--- a/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts
+++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2.dts
@@ -252,11 +252,44 @@
reg = <1>;
 
dsi_out: endpoint {
+   remote-endpoint = <_in>;
samsung,burst-clock-frequency = <51200>;
samsung,esc-clock-frequency = <1600>;
};
};
};
+
+   panel@0 {
+   compatible = "samsung,s6e3ha2";
+   reg = <0>;
+   vdd3-supply = <_reg>;
+   vci-supply = <_reg>;
+   reset-gpios = < 0 GPIO_ACTIVE_HIGH>;
+   enable-gpios = < 5 GPIO_ACTIVE_HIGH>;
+   te-gpios = < 3 GPIO_ACTIVE_HIGH>;
+   power-on-delay = <120>;
+   reset-delay = <5>;
+
+   display-timings {
+   timing-0 {
+   clock-frequency = <1487>;
+   hactive = <1440>;
+   vactive = <2560>;
+   hfront-porch = <1>;
+   hback-porch = <1>;
+   hsync-len = <1>;
+   vfront-porch = <1>;
+   vback-porch = <15>;
+   vsync-len = <1>;
+   };
+   };
+
+   port {
+   dsi_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
 };
 
 _0 {
-- 
1.9.1



[PATCH 0/2] Add support for the S6E3HA2 panel on TM2 board

2016-12-13 Thread Hoegeun Kwon
Purpose of this patch is add support for S6E3HA2 AMOLED panel on
the TM2 board. The first patch adds support for S6E3HA2 panel
device tree document and driver, the second patch add support for
S6E3HA2 panel device tree.

Hoegeun Kwon (1):
  drm/panel: Add support for S6E3HA2 panel driver on TM2 board

Hyungwon Hwang (1):
  arm64: dts: exynos: Add support for S6E3HA2 panel device on TM2 board

 .../bindings/display/panel/samsung,s6e3ha2.txt |  52 ++
 arch/arm64/boot/dts/exynos/exynos5433-tm2.dts  |  33 +
 drivers/gpu/drm/panel/Kconfig  |   6 +
 drivers/gpu/drm/panel/Makefile |   1 +
 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c  | 756 +
 5 files changed, 848 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha2.txt
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c

-- 
1.9.1



Re: [PATCH v2] crypto: sun4i-ss: support the Security System PRNG

2016-12-13 Thread Corentin Labbe
On Wed, Dec 14, 2016 at 01:05:51PM +0800, Herbert Xu wrote:
> On Tue, Dec 13, 2016 at 03:10:59PM +0100, Corentin Labbe wrote:
> >
> > I have found two solutions:
> 
> No we already have algif_rng so let's not confuse things even
> further by making hwrng take PRNGs.
> 

But algif_rng is not accessible from user space without any coding.
So no easy "random" data with some cat /dev/.

Clearly users of the 3 already intree hw_random PRNG will see that like a 
regresion.

Regards
Corentin Labbe


Re: [PATCH v2] crypto: sun4i-ss: support the Security System PRNG

2016-12-13 Thread Corentin Labbe
On Wed, Dec 14, 2016 at 01:05:51PM +0800, Herbert Xu wrote:
> On Tue, Dec 13, 2016 at 03:10:59PM +0100, Corentin Labbe wrote:
> >
> > I have found two solutions:
> 
> No we already have algif_rng so let's not confuse things even
> further by making hwrng take PRNGs.
> 

But algif_rng is not accessible from user space without any coding.
So no easy "random" data with some cat /dev/.

Clearly users of the 3 already intree hw_random PRNG will see that like a 
regresion.

Regards
Corentin Labbe


Re: [PATCH] ipmi: bt-bmc: Use a regmap for register access

2016-12-13 Thread Andrew Jeffery
On Wed, 2016-12-14 at 11:59 +1030, Joel Stanley wrote:
> > On Tue, Dec 6, 2016 at 1:27 PM, Andrew Jeffery  wrote:
> > The registers for the bt-bmc device live under the Aspeed LPC
> > controller. Devicetree bindings have recently been introduced for the
> > LPC controller where the "host" portion of the LPC register space is
> > described as a syscon device. Future devicetrees describing the bt-bmc
> > device should nest its node under the appropriate "simple-mfd", "syscon"
> > compatible node.
> > 
> > This change allows the bt-bmc driver to function with both syscon and
> > non-syscon- based devicetree descriptions by always using a regmap for
> > register access, either retrieved from the parent syscon device or
> > instantiated if none exists.
> > 
> > The patch has been tested on an OpenPOWER Palmetto machine, successfully
> > booting, rebooting and powering down the host.
> > 
> > > > Signed-off-by: Andrew Jeffery 
> > ---
> >  drivers/char/ipmi/Kconfig  |  1 +
> >  drivers/char/ipmi/bt-bmc.c | 82 
> > ++
> >  2 files changed, 62 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig
> > index 7f816655cbbf..b5d48d9af124 100644
> > --- a/drivers/char/ipmi/Kconfig
> > +++ b/drivers/char/ipmi/Kconfig
> > @@ -79,6 +79,7 @@ endif # IPMI_HANDLER
> > 
> >  config ASPEED_BT_IPMI_BMC
> > depends on ARCH_ASPEED
> 
> If you do a v2 of this series it would be great to add || COMPILE_TEST here.
> 
> > +depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
> > tristate "BT IPMI bmc driver"
> > help
> >   Provides a driver for the BT (Block Transfer) IPMI interface
> > diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
> > index fc9e8891eae3..ca1e20f6c6c5 100644
> > --- a/drivers/char/ipmi/bt-bmc.c
> > +++ b/drivers/char/ipmi/bt-bmc.c
> > @@ -12,10 +12,13 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > 
> > @@ -60,7 +63,8 @@
> >  struct bt_bmc {
> > struct device   dev;
> > struct miscdevice   miscdev;
> > -   void __iomem*base;
> > +   struct regmap   *map;
> > +   int offset;
> > int irq;
> > wait_queue_head_t   queue;
> > struct timer_list   poll_timer;
> > @@ -69,14 +73,31 @@ struct bt_bmc {
> > 
> >  static atomic_t open_count = ATOMIC_INIT(0);
> > 
> > +static struct regmap_config bt_regmap_cfg = {
> 
> const?

Good point. Is it worth a v2?

> 
> > +   .reg_bits = 32,
> > +   .val_bits = 32,
> > +   .reg_stride = 4,
> > +};
> > +
> >  static u8 bt_inb(struct bt_bmc *bt_bmc, int reg)
> >  {
> > -   return ioread8(bt_bmc->base + reg);
> > +   uint32_t val = 0;
> > +   int rc;
> > +
> > +   rc = regmap_read(bt_bmc->map, bt_bmc->offset + reg, );
> > +   WARN(rc != 0, "%s:%d: regmap_read() failed: %d\n",
> > +   __FILE__, __LINE__, rc);
> 
> Under what circumstances do we expect the read to fail?

By the regmap_read() implementation for MMIO it should never fail. If
it does, then we should tell someone about it.

> 
> This isn't much cleaner, but I prefer it slightly:
> 
> rc = regmap_read(bt_bmc->map, bt_bmc->offset + reg, );
> if (rc) {
>    dev_warn(bt_bmc->dev, "read failed %d\n", rc);
>    return rc;
> }
> 
> return val;

bt_inb() currently returns a u8 type, and as such no caller performs
error checking. While your suggestion might seem slightly preferable,
it feels likely "slightly preferable" might fail to take into account
the cascading effect of changing the return type and testing for errors
at each of the (transitive) call-sites.

I think the additional code required makes your suggestion less
attractive given that the call should never fail.

If you decide you feel strongly about it I can make the change.

> 
> > +
> > +   return rc == 0 ? (u8) val : 0;
> >  }
> > 
> >  static void bt_outb(struct bt_bmc *bt_bmc, u8 data, int reg)
> >  {
> > -   iowrite8(data, bt_bmc->base + reg);
> > +   int rc;
> > +
> > +   rc = regmap_write(bt_bmc->map, bt_bmc->offset + reg, data);
> > +   WARN(rc != 0, "%s:%d: regmap_write() failed: %d\n",
> > +   __FILE__, __LINE__, rc);
> >  }
> > 
> >  static void clr_rd_ptr(struct bt_bmc *bt_bmc)
> > @@ -367,14 +388,18 @@ static irqreturn_t bt_bmc_irq(int irq, void *arg)
> >  {
> > struct bt_bmc *bt_bmc = arg;
> > u32 reg;
> > +   int rc;
> > +
> > +   rc = regmap_read(bt_bmc->map, bt_bmc->offset + BT_CR2, );
> > +   if (rc)
> > +   return IRQ_NONE;
> > 
> > -   reg = ioread32(bt_bmc->base + BT_CR2);
> > reg &= BT_CR2_IRQ_H2B | BT_CR2_IRQ_HBUSY;
> > if (!reg)
> > 

Re: [PATCH] ipmi: bt-bmc: Use a regmap for register access

2016-12-13 Thread Andrew Jeffery
On Wed, 2016-12-14 at 11:59 +1030, Joel Stanley wrote:
> > On Tue, Dec 6, 2016 at 1:27 PM, Andrew Jeffery  wrote:
> > The registers for the bt-bmc device live under the Aspeed LPC
> > controller. Devicetree bindings have recently been introduced for the
> > LPC controller where the "host" portion of the LPC register space is
> > described as a syscon device. Future devicetrees describing the bt-bmc
> > device should nest its node under the appropriate "simple-mfd", "syscon"
> > compatible node.
> > 
> > This change allows the bt-bmc driver to function with both syscon and
> > non-syscon- based devicetree descriptions by always using a regmap for
> > register access, either retrieved from the parent syscon device or
> > instantiated if none exists.
> > 
> > The patch has been tested on an OpenPOWER Palmetto machine, successfully
> > booting, rebooting and powering down the host.
> > 
> > > > Signed-off-by: Andrew Jeffery 
> > ---
> >  drivers/char/ipmi/Kconfig  |  1 +
> >  drivers/char/ipmi/bt-bmc.c | 82 
> > ++
> >  2 files changed, 62 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig
> > index 7f816655cbbf..b5d48d9af124 100644
> > --- a/drivers/char/ipmi/Kconfig
> > +++ b/drivers/char/ipmi/Kconfig
> > @@ -79,6 +79,7 @@ endif # IPMI_HANDLER
> > 
> >  config ASPEED_BT_IPMI_BMC
> > depends on ARCH_ASPEED
> 
> If you do a v2 of this series it would be great to add || COMPILE_TEST here.
> 
> > +depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
> > tristate "BT IPMI bmc driver"
> > help
> >   Provides a driver for the BT (Block Transfer) IPMI interface
> > diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
> > index fc9e8891eae3..ca1e20f6c6c5 100644
> > --- a/drivers/char/ipmi/bt-bmc.c
> > +++ b/drivers/char/ipmi/bt-bmc.c
> > @@ -12,10 +12,13 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > 
> > @@ -60,7 +63,8 @@
> >  struct bt_bmc {
> > struct device   dev;
> > struct miscdevice   miscdev;
> > -   void __iomem*base;
> > +   struct regmap   *map;
> > +   int offset;
> > int irq;
> > wait_queue_head_t   queue;
> > struct timer_list   poll_timer;
> > @@ -69,14 +73,31 @@ struct bt_bmc {
> > 
> >  static atomic_t open_count = ATOMIC_INIT(0);
> > 
> > +static struct regmap_config bt_regmap_cfg = {
> 
> const?

Good point. Is it worth a v2?

> 
> > +   .reg_bits = 32,
> > +   .val_bits = 32,
> > +   .reg_stride = 4,
> > +};
> > +
> >  static u8 bt_inb(struct bt_bmc *bt_bmc, int reg)
> >  {
> > -   return ioread8(bt_bmc->base + reg);
> > +   uint32_t val = 0;
> > +   int rc;
> > +
> > +   rc = regmap_read(bt_bmc->map, bt_bmc->offset + reg, );
> > +   WARN(rc != 0, "%s:%d: regmap_read() failed: %d\n",
> > +   __FILE__, __LINE__, rc);
> 
> Under what circumstances do we expect the read to fail?

By the regmap_read() implementation for MMIO it should never fail. If
it does, then we should tell someone about it.

> 
> This isn't much cleaner, but I prefer it slightly:
> 
> rc = regmap_read(bt_bmc->map, bt_bmc->offset + reg, );
> if (rc) {
>    dev_warn(bt_bmc->dev, "read failed %d\n", rc);
>    return rc;
> }
> 
> return val;

bt_inb() currently returns a u8 type, and as such no caller performs
error checking. While your suggestion might seem slightly preferable,
it feels likely "slightly preferable" might fail to take into account
the cascading effect of changing the return type and testing for errors
at each of the (transitive) call-sites.

I think the additional code required makes your suggestion less
attractive given that the call should never fail.

If you decide you feel strongly about it I can make the change.

> 
> > +
> > +   return rc == 0 ? (u8) val : 0;
> >  }
> > 
> >  static void bt_outb(struct bt_bmc *bt_bmc, u8 data, int reg)
> >  {
> > -   iowrite8(data, bt_bmc->base + reg);
> > +   int rc;
> > +
> > +   rc = regmap_write(bt_bmc->map, bt_bmc->offset + reg, data);
> > +   WARN(rc != 0, "%s:%d: regmap_write() failed: %d\n",
> > +   __FILE__, __LINE__, rc);
> >  }
> > 
> >  static void clr_rd_ptr(struct bt_bmc *bt_bmc)
> > @@ -367,14 +388,18 @@ static irqreturn_t bt_bmc_irq(int irq, void *arg)
> >  {
> > struct bt_bmc *bt_bmc = arg;
> > u32 reg;
> > +   int rc;
> > +
> > +   rc = regmap_read(bt_bmc->map, bt_bmc->offset + BT_CR2, );
> > +   if (rc)
> > +   return IRQ_NONE;
> > 
> > -   reg = ioread32(bt_bmc->base + BT_CR2);
> > reg &= BT_CR2_IRQ_H2B | BT_CR2_IRQ_HBUSY;
> > if (!reg)
> > return IRQ_NONE;
> > 
> > /* 

RE: ATH9 driver issues on ARM64

2016-12-13 Thread Bharat Kumar Gogada
> On Sat, Dec 10, 2016 at 02:40:48PM +, Bharat Kumar Gogada wrote:
> > Hi,
> >
> > After taking some more lecroy traces, we see that after 2nd ASSERT from EP
> on ARM64 we see continuous data movement of 32 dwords or 12 dwords and
> never sign of DEASSERT.
> > Comparatively on working traces (x86) after 2nd assert there are only BAR
> register reads and writes and then DEASSERT, for almost most of the interrupts
> and we haven't seen 12 or 32 dwords data movement on this trace.
> >
> > I did not work on EP wifi/network drivers, any help why EP needs those many
> number of data at scan time ?
> 
> The device doesn't know whether it's in an x86 or an arm64 system.  If it 
> works
> differently, it must be because the PCI core or the driver is programming the
> device differently.
> 
> You should be able to match up Memory transactions from the host in the trace
> with things the driver does.  For example, if you see an Assert_INTx message
> from the device, you should eventually see a Memory Read from the host to get
> the ISR, i.e., some read done in the bowels of ath9k_hw_getisr().
> 
> I don't know how the ath9k device works, but there must be some Memory Read
> or Write done by the driver that tells the device "we've handled this 
> interrupt".
> The device should then send a Deassert_INTx; of course, if the device still
> requires service, e.g., because it has received more packets, it might leave 
> the
> INTx asserted.
> 
> I doubt you'd see exactly the same traces on x86 and arm64 because they aren't
> seeing the same network packets and the driver is executing at different 
> rates.
> But you should at least be able to identify interrupt assertion and the 
> actions of
> the driver's interrupt service routine.


Thanks Bjorn.

As you mentioned we did try to debug in that path. After we start scan after 
2nd ASSERT we see lots of 32 and 12 dword
data, and in function
void ath9k_hw_enable_interrupts(struct ath_hw *ah) 
{
...
..
REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
// EP driver hangs at this 
position after 2nd ASSERT
// The following writes are not 
happening
if (!AR_SREV_9100(ah)) {
REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, async_mask);
REG_WRITE(ah, AR_INTR_ASYNC_MASK, async_mask);

REG_WRITE(ah, AR_INTR_SYNC_ENABLE, sync_default);
REG_WRITE(ah, AR_INTR_SYNC_MASK, sync_default);
}   
ath_dbg(common, INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
}
The above funtion is invoked from tasklet.
I tried several boots every it stops here. The condition (!AR_SREV_9100(ah)) is 
true as per before 1st ASSERT handling.

Regards,
Bharat

> 
> > > Hello there,
> > >
> > > as this is a thread about ath9k and ARM64, i'm not sure if i should
> > > answer here or not, but i have similar "stalls" with ath9k on x86_64
> > > (starting with 4.9rc), stack trace is posted down below where the original
> ARM64 stall traces are.
> > >
> > > Greetings,
> > >
> > > Tobias
> > >
> > >
> > > On 08.12.2016 18:36, Kalle Valo wrote:
> > > > Bharat Kumar Gogada  writes:
> > > >
> > > >>   > [+cc Kalle, ath9k list]
> > > > Thanks, but please also CC linux-wireless. Full thread below for
> > > > the folks there.
> > > >
> > > >>> On Thu, Dec 08, 2016 at 01:49:42PM +, Bharat Kumar Gogada
> wrote:
> > >  Hi,
> > > 
> > >  Did anyone test Atheros ATH9
> > >  driver(drivers/net/wireless/ath/ath9k/)
> > >  on ARM64.  The end point is TP link wifi card with which
> > >  supports only legacy interrupts.
> > > >>> If it works on other arches and the arm64 PCI enumeration works,
> > > >>> my first guess would be an INTx issue, e.g., maybe the driver is
> > > >>> waiting for an interrupt that never arrives.
> > > >> We are not sure for now.
> > >  We are trying to test it on ARM64 with
> > >  (drivers/pci/host/pcie-xilinx-nwl.c) as root port.
> > > 
> > >  EP is getting enumerated and able to link up.
> > > 
> > >  But when we start scan system gets hanged.
> > > >>> When you say the system hangs when you start a scan, I assume
> > > >>> you mean a wifi scan, not the PCI enumeration.  A problem with a
> > > >>> wifi scan might cause a *process* to hang, but it shouldn't hang
> > > >>> the entire system.
> > > >>>
> > > >> Yes wifi scan.
> > >  When we took trace we see that after we start scan assert
> > >  message is sent but there is no de assert from end point.
> > > >>> Are you talking about a trace from a PCIe analyzer?  Do you see
> > > >>> an Assert_INTx PCIe message on the link?
> > > >>>
> > > >> Yes lecroy trace, yes we do see Assert_INTx and Deassert_INTx
> > > >> happening
> > > when we do interface link up.
> > > >> When we have less debug prints in Atheros 

RE: ATH9 driver issues on ARM64

2016-12-13 Thread Bharat Kumar Gogada
> On Sat, Dec 10, 2016 at 02:40:48PM +, Bharat Kumar Gogada wrote:
> > Hi,
> >
> > After taking some more lecroy traces, we see that after 2nd ASSERT from EP
> on ARM64 we see continuous data movement of 32 dwords or 12 dwords and
> never sign of DEASSERT.
> > Comparatively on working traces (x86) after 2nd assert there are only BAR
> register reads and writes and then DEASSERT, for almost most of the interrupts
> and we haven't seen 12 or 32 dwords data movement on this trace.
> >
> > I did not work on EP wifi/network drivers, any help why EP needs those many
> number of data at scan time ?
> 
> The device doesn't know whether it's in an x86 or an arm64 system.  If it 
> works
> differently, it must be because the PCI core or the driver is programming the
> device differently.
> 
> You should be able to match up Memory transactions from the host in the trace
> with things the driver does.  For example, if you see an Assert_INTx message
> from the device, you should eventually see a Memory Read from the host to get
> the ISR, i.e., some read done in the bowels of ath9k_hw_getisr().
> 
> I don't know how the ath9k device works, but there must be some Memory Read
> or Write done by the driver that tells the device "we've handled this 
> interrupt".
> The device should then send a Deassert_INTx; of course, if the device still
> requires service, e.g., because it has received more packets, it might leave 
> the
> INTx asserted.
> 
> I doubt you'd see exactly the same traces on x86 and arm64 because they aren't
> seeing the same network packets and the driver is executing at different 
> rates.
> But you should at least be able to identify interrupt assertion and the 
> actions of
> the driver's interrupt service routine.


Thanks Bjorn.

As you mentioned we did try to debug in that path. After we start scan after 
2nd ASSERT we see lots of 32 and 12 dword
data, and in function
void ath9k_hw_enable_interrupts(struct ath_hw *ah) 
{
...
..
REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
// EP driver hangs at this 
position after 2nd ASSERT
// The following writes are not 
happening
if (!AR_SREV_9100(ah)) {
REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, async_mask);
REG_WRITE(ah, AR_INTR_ASYNC_MASK, async_mask);

REG_WRITE(ah, AR_INTR_SYNC_ENABLE, sync_default);
REG_WRITE(ah, AR_INTR_SYNC_MASK, sync_default);
}   
ath_dbg(common, INTERRUPT, "AR_IMR 0x%x IER 0x%x\n",
REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER));
}
The above funtion is invoked from tasklet.
I tried several boots every it stops here. The condition (!AR_SREV_9100(ah)) is 
true as per before 1st ASSERT handling.

Regards,
Bharat

> 
> > > Hello there,
> > >
> > > as this is a thread about ath9k and ARM64, i'm not sure if i should
> > > answer here or not, but i have similar "stalls" with ath9k on x86_64
> > > (starting with 4.9rc), stack trace is posted down below where the original
> ARM64 stall traces are.
> > >
> > > Greetings,
> > >
> > > Tobias
> > >
> > >
> > > On 08.12.2016 18:36, Kalle Valo wrote:
> > > > Bharat Kumar Gogada  writes:
> > > >
> > > >>   > [+cc Kalle, ath9k list]
> > > > Thanks, but please also CC linux-wireless. Full thread below for
> > > > the folks there.
> > > >
> > > >>> On Thu, Dec 08, 2016 at 01:49:42PM +, Bharat Kumar Gogada
> wrote:
> > >  Hi,
> > > 
> > >  Did anyone test Atheros ATH9
> > >  driver(drivers/net/wireless/ath/ath9k/)
> > >  on ARM64.  The end point is TP link wifi card with which
> > >  supports only legacy interrupts.
> > > >>> If it works on other arches and the arm64 PCI enumeration works,
> > > >>> my first guess would be an INTx issue, e.g., maybe the driver is
> > > >>> waiting for an interrupt that never arrives.
> > > >> We are not sure for now.
> > >  We are trying to test it on ARM64 with
> > >  (drivers/pci/host/pcie-xilinx-nwl.c) as root port.
> > > 
> > >  EP is getting enumerated and able to link up.
> > > 
> > >  But when we start scan system gets hanged.
> > > >>> When you say the system hangs when you start a scan, I assume
> > > >>> you mean a wifi scan, not the PCI enumeration.  A problem with a
> > > >>> wifi scan might cause a *process* to hang, but it shouldn't hang
> > > >>> the entire system.
> > > >>>
> > > >> Yes wifi scan.
> > >  When we took trace we see that after we start scan assert
> > >  message is sent but there is no de assert from end point.
> > > >>> Are you talking about a trace from a PCIe analyzer?  Do you see
> > > >>> an Assert_INTx PCIe message on the link?
> > > >>>
> > > >> Yes lecroy trace, yes we do see Assert_INTx and Deassert_INTx
> > > >> happening
> > > when we do interface link up.
> > > >> When we have less debug prints in Atheros driver, and do wifi
> > > >> scan we 

Re: [PATCH] include/linux/kernel.h: fixed coding style issues

2016-12-13 Thread Joe Perches
On Wed, 2016-12-14 at 00:52 +, Piotr Gregor wrote:
> Apply coding style suggested by Documentation/CodingStyle
> and checkpatch.pl script. Fix 59 warnings and 24 errors
> reported by checkpatch.pl

Hello Piotr.

Please make the first patch you submit against something in
drivers/staging and not a core kernel file like kernel.h

Welcome in any case.  Joe


Re: [PATCH] include/linux/kernel.h: fixed coding style issues

2016-12-13 Thread Joe Perches
On Wed, 2016-12-14 at 00:52 +, Piotr Gregor wrote:
> Apply coding style suggested by Documentation/CodingStyle
> and checkpatch.pl script. Fix 59 warnings and 24 errors
> reported by checkpatch.pl

Hello Piotr.

Please make the first patch you submit against something in
drivers/staging and not a core kernel file like kernel.h

Welcome in any case.  Joe


Re: Scheduler patches: 6x performance increase when system is under heavy load

2016-12-13 Thread Alexandre-Xavier Labonté-Lamoureux
> Which of the 4 patches does this?

I used all the 4 patches at the same time. Each patch fixes a
different bug. Would you like me to try each of them individually?
Were you already aware of each of these bugs?

> Also, what hypervisor are you using and what does the output of booting
> with "sched_debug" look like?

I was running the distro in VirualBox on Fedora. Here's the info from
/proc/sched_debug:
https://justpaste.it/11dhb
dmesg: https://justpaste.it/11dhr

> Lastly, can you reproduce on real hardware?

No. On real hardware, I tested in Ubuntu on an i7-4790 3.60GHz CPU
without disabling HT and I saw no difference between CFS, the patched
kernel and MuQSS. If I get to know a reason why one would be better
than the other, I'd take the time to test it on more hardware. I'm
curious how I got such a performance improvement in my VM.

On Tue, Dec 13, 2016 at 8:40 AM, Peter Zijlstra  wrote:
> On Sun, Dec 11, 2016 at 04:41:51PM -0500, Alexandre-Xavier Labonté-Lamoureux 
> wrote:
>>
>> Here are my results (using "time make -j32" on my VM that has 4 cores):
>>
>> Kernel 4.8.14
>>   real 26m56.151s
>>   user 79m52.472s
>>   sys 7m42.964s
>>
>> Same kernel, but patched:
>>   real 4m25.238s
>>   user 13m52.932s
>>   sys 1m25.820s
>>
>> I hope you guys will look into this.
>
> Which of the 4 patches does this?
>
> Also, what hypervisor are you using and what does the output of booting
> with "sched_debug" look like?
>
> Lastly, can you reproduce on real hardware?


Re: Scheduler patches: 6x performance increase when system is under heavy load

2016-12-13 Thread Alexandre-Xavier Labonté-Lamoureux
> Which of the 4 patches does this?

I used all the 4 patches at the same time. Each patch fixes a
different bug. Would you like me to try each of them individually?
Were you already aware of each of these bugs?

> Also, what hypervisor are you using and what does the output of booting
> with "sched_debug" look like?

I was running the distro in VirualBox on Fedora. Here's the info from
/proc/sched_debug:
https://justpaste.it/11dhb
dmesg: https://justpaste.it/11dhr

> Lastly, can you reproduce on real hardware?

No. On real hardware, I tested in Ubuntu on an i7-4790 3.60GHz CPU
without disabling HT and I saw no difference between CFS, the patched
kernel and MuQSS. If I get to know a reason why one would be better
than the other, I'd take the time to test it on more hardware. I'm
curious how I got such a performance improvement in my VM.

On Tue, Dec 13, 2016 at 8:40 AM, Peter Zijlstra  wrote:
> On Sun, Dec 11, 2016 at 04:41:51PM -0500, Alexandre-Xavier Labonté-Lamoureux 
> wrote:
>>
>> Here are my results (using "time make -j32" on my VM that has 4 cores):
>>
>> Kernel 4.8.14
>>   real 26m56.151s
>>   user 79m52.472s
>>   sys 7m42.964s
>>
>> Same kernel, but patched:
>>   real 4m25.238s
>>   user 13m52.932s
>>   sys 1m25.820s
>>
>> I hope you guys will look into this.
>
> Which of the 4 patches does this?
>
> Also, what hypervisor are you using and what does the output of booting
> with "sched_debug" look like?
>
> Lastly, can you reproduce on real hardware?


[PATCH] drm/mediatek: Support UYVY and YUYV format for overlay

2016-12-13 Thread Bibby Hsieh
MT8173 overlay can support UYVY and YUYV format,
we add the format in DRM driver.

Signed-off-by: Bibby Hsieh 
---
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c  | 6 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index 019b7ca..0a340f3 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -44,6 +44,8 @@
 #define OVL_CON_CLRFMT_RGB888  (1 << 12)
 #define OVL_CON_CLRFMT_RGBA(2 << 12)
 #define OVL_CON_CLRFMT_ARGB(3 << 12)
+#define OVL_CON_CLRFMT_UYVY(4 << 12)
+#define OVL_CON_CLRFMT_YUYV(5 << 12)
 #defineOVL_CON_AEN BIT(8)
 #defineOVL_CON_ALPHA   0xff
 
@@ -161,6 +163,10 @@ static unsigned int ovl_fmt_convert(unsigned int fmt)
case DRM_FORMAT_XBGR:
case DRM_FORMAT_ABGR:
return OVL_CON_CLRFMT_RGBA | OVL_CON_BYTE_SWAP;
+   case DRM_FORMAT_YUYV:
+   return OVL_CON_CLRFMT_YUYV;
+   case DRM_FORMAT_UYVY:
+   return OVL_CON_CLRFMT_UYVY;
}
 }
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c 
b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index c461a23..b94c6ee 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -28,6 +28,8 @@
DRM_FORMAT_XRGB,
DRM_FORMAT_ARGB,
DRM_FORMAT_RGB565,
+   DRM_FORMAT_YUYV,
+   DRM_FORMAT_UYVY,
 };
 
 static void mtk_plane_reset(struct drm_plane *plane)
-- 
1.9.1



[PATCH] drm/mediatek: Support UYVY and YUYV format for overlay

2016-12-13 Thread Bibby Hsieh
MT8173 overlay can support UYVY and YUYV format,
we add the format in DRM driver.

Signed-off-by: Bibby Hsieh 
---
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c  | 6 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index 019b7ca..0a340f3 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -44,6 +44,8 @@
 #define OVL_CON_CLRFMT_RGB888  (1 << 12)
 #define OVL_CON_CLRFMT_RGBA(2 << 12)
 #define OVL_CON_CLRFMT_ARGB(3 << 12)
+#define OVL_CON_CLRFMT_UYVY(4 << 12)
+#define OVL_CON_CLRFMT_YUYV(5 << 12)
 #defineOVL_CON_AEN BIT(8)
 #defineOVL_CON_ALPHA   0xff
 
@@ -161,6 +163,10 @@ static unsigned int ovl_fmt_convert(unsigned int fmt)
case DRM_FORMAT_XBGR:
case DRM_FORMAT_ABGR:
return OVL_CON_CLRFMT_RGBA | OVL_CON_BYTE_SWAP;
+   case DRM_FORMAT_YUYV:
+   return OVL_CON_CLRFMT_YUYV;
+   case DRM_FORMAT_UYVY:
+   return OVL_CON_CLRFMT_UYVY;
}
 }
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c 
b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index c461a23..b94c6ee 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -28,6 +28,8 @@
DRM_FORMAT_XRGB,
DRM_FORMAT_ARGB,
DRM_FORMAT_RGB565,
+   DRM_FORMAT_YUYV,
+   DRM_FORMAT_UYVY,
 };
 
 static void mtk_plane_reset(struct drm_plane *plane)
-- 
1.9.1



Re: [PATCH v2] crypto: sun4i-ss: support the Security System PRNG

2016-12-13 Thread Herbert Xu
On Tue, Dec 13, 2016 at 03:10:59PM +0100, Corentin Labbe wrote:
>
> I have found two solutions:

No we already have algif_rng so let's not confuse things even
further by making hwrng take PRNGs.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH v2] crypto: sun4i-ss: support the Security System PRNG

2016-12-13 Thread Herbert Xu
On Tue, Dec 13, 2016 at 03:10:59PM +0100, Corentin Labbe wrote:
>
> I have found two solutions:

No we already have algif_rng so let's not confuse things even
further by making hwrng take PRNGs.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] drm/bridge: analogix_dp: set the DPCD600 during disabling the psr

2016-12-13 Thread Archit Taneja

Hi,

On 12/12/2016 08:28 PM, Sean Paul wrote:

On Fri, Dec 9, 2016 at 9:49 PM, Caesar Wang  wrote:

Look likes, the BOE panel FW didn't ack the DPCD600 signal from the host
device, that will cause the panel hang on the startup display.
The root cause we use the fast link mode during enter and exit the psr,
this issue is gone if switching the fast link to main link mode.



Cc: Archit Taneja 


Do we want this as a fix in 4.10? Or is it okay to get it in 4.11?
In other words, should this go to drm-misc-next or drm-misc-fixes?

Thanks,
Archit




Signed-off-by: Caesar Wang 
---

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 6e0447f..6a5347b 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -133,6 +133,7 @@ int analogix_dp_disable_psr(struct device *dev)
 {
struct analogix_dp_device *dp = dev_get_drvdata(dev);
struct edp_vsc_psr psr_vsc;
+   int ret;

if (!dp->psr_support)
return -EINVAL;
@@ -147,6 +148,10 @@ int analogix_dp_disable_psr(struct device *dev)
psr_vsc.DB0 = 0;
psr_vsc.DB1 = 0;

+   ret = drm_dp_dpcd_writeb(>aux, DP_SET_POWER, DP_SET_POWER_D0);
+   if (ret != 1)
+   dev_err(dp->dev, "Failed to set DP Power0 %d\n", ret);
+
analogix_dp_send_psr_spd(dp, _vsc);
return 0;
 }
--
2.7.4



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH] drm/bridge: analogix_dp: set the DPCD600 during disabling the psr

2016-12-13 Thread Archit Taneja

Hi,

On 12/12/2016 08:28 PM, Sean Paul wrote:

On Fri, Dec 9, 2016 at 9:49 PM, Caesar Wang  wrote:

Look likes, the BOE panel FW didn't ack the DPCD600 signal from the host
device, that will cause the panel hang on the startup display.
The root cause we use the fast link mode during enter and exit the psr,
this issue is gone if switching the fast link to main link mode.



Cc: Archit Taneja 


Do we want this as a fix in 4.10? Or is it okay to get it in 4.11?
In other words, should this go to drm-misc-next or drm-misc-fixes?

Thanks,
Archit




Signed-off-by: Caesar Wang 
---

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 6e0447f..6a5347b 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -133,6 +133,7 @@ int analogix_dp_disable_psr(struct device *dev)
 {
struct analogix_dp_device *dp = dev_get_drvdata(dev);
struct edp_vsc_psr psr_vsc;
+   int ret;

if (!dp->psr_support)
return -EINVAL;
@@ -147,6 +148,10 @@ int analogix_dp_disable_psr(struct device *dev)
psr_vsc.DB0 = 0;
psr_vsc.DB1 = 0;

+   ret = drm_dp_dpcd_writeb(>aux, DP_SET_POWER, DP_SET_POWER_D0);
+   if (ret != 1)
+   dev_err(dp->dev, "Failed to set DP Power0 %d\n", ret);
+
analogix_dp_send_psr_spd(dp, _vsc);
return 0;
 }
--
2.7.4



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v7 3/5] drm: bridge: add support for TI ths8135

2016-12-13 Thread Archit Taneja



On 12/13/2016 03:39 PM, Bartosz Golaszewski wrote:

THS8135 is a configurable video DAC, but no configuration is actually
necessary to make it work.

For now use the dumb-vga-dac driver to support it.


Queued to drm-misc-next

Archit



Signed-off-by: Bartosz Golaszewski 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/dumb-vga-dac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index e570698..86e9f9c 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -237,6 +237,7 @@ static int dumb_vga_remove(struct platform_device *pdev)

 static const struct of_device_id dumb_vga_match[] = {
{ .compatible = "dumb-vga-dac" },
+   { .compatible = "ti,ths8135" },
{},
 };
 MODULE_DEVICE_TABLE(of, dumb_vga_match);



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v7 3/5] drm: bridge: add support for TI ths8135

2016-12-13 Thread Archit Taneja



On 12/13/2016 03:39 PM, Bartosz Golaszewski wrote:

THS8135 is a configurable video DAC, but no configuration is actually
necessary to make it work.

For now use the dumb-vga-dac driver to support it.


Queued to drm-misc-next

Archit



Signed-off-by: Bartosz Golaszewski 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/dumb-vga-dac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index e570698..86e9f9c 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -237,6 +237,7 @@ static int dumb_vga_remove(struct platform_device *pdev)

 static const struct of_device_id dumb_vga_match[] = {
{ .compatible = "dumb-vga-dac" },
+   { .compatible = "ti,ths8135" },
{},
 };
 MODULE_DEVICE_TABLE(of, dumb_vga_match);



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v7 2/5] drm: bridge: add DT bindings for TI ths8135

2016-12-13 Thread Archit Taneja

Hi,

On 12/13/2016 03:39 PM, Bartosz Golaszewski wrote:

THS8135 is a configurable video DAC. Add DT bindings for this chip.


Queued to drm-misc-next


Signed-off-by: Bartosz Golaszewski 
Reviewed-by: Laurent Pinchart 
Acked-by: Rob Herring 
---
 .../bindings/display/bridge/ti,ths8135.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt

diff --git a/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt 
b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
new file mode 100644
index 000..6ec1a88
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
@@ -0,0 +1,46 @@
+THS8135 Video DAC
+-
+
+This is the binding for Texas Instruments THS8135 Video DAC bridge.
+
+Required properties:
+
+- compatible: Must be "ti,ths8135"
+
+Required nodes:
+
+This device has two video ports. Their connections are modelled using the OF
+graph bindings specified in Documentation/devicetree/bindings/graph.txt.
+
+- Video port 0 for RGB input
+- Video port 1 for VGA output
+
+Example
+---
+
+vga-bridge {
+   compatible = "ti,ths8135";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   vga_bridge_in: endpoint {
+   remote-endpoint = <_out_vga>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   vga_bridge_out: endpoint {
+   remote-endpoint = <_con_in>;
+   };
+   };
+   };
+};



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v7 2/5] drm: bridge: add DT bindings for TI ths8135

2016-12-13 Thread Archit Taneja

Hi,

On 12/13/2016 03:39 PM, Bartosz Golaszewski wrote:

THS8135 is a configurable video DAC. Add DT bindings for this chip.


Queued to drm-misc-next


Signed-off-by: Bartosz Golaszewski 
Reviewed-by: Laurent Pinchart 
Acked-by: Rob Herring 
---
 .../bindings/display/bridge/ti,ths8135.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt

diff --git a/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt 
b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
new file mode 100644
index 000..6ec1a88
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
@@ -0,0 +1,46 @@
+THS8135 Video DAC
+-
+
+This is the binding for Texas Instruments THS8135 Video DAC bridge.
+
+Required properties:
+
+- compatible: Must be "ti,ths8135"
+
+Required nodes:
+
+This device has two video ports. Their connections are modelled using the OF
+graph bindings specified in Documentation/devicetree/bindings/graph.txt.
+
+- Video port 0 for RGB input
+- Video port 1 for VGA output
+
+Example
+---
+
+vga-bridge {
+   compatible = "ti,ths8135";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   vga_bridge_in: endpoint {
+   remote-endpoint = <_out_vga>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   vga_bridge_out: endpoint {
+   remote-endpoint = <_con_in>;
+   };
+   };
+   };
+};



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v2] keys/encrypted: Fix two crypto-on-the-stack bugs

2016-12-13 Thread Herbert Xu
On Tue, Dec 13, 2016 at 06:53:03PM -0800, Andy Lutomirski wrote:
> On Tue, Dec 13, 2016 at 6:48 PM, Andy Lutomirski  wrote:
> > The driver put a constant buffer of all zeros on the stack and
> > pointed a scatterlist entry at it in two places.  This doesn't work
> > with virtual stacks.  Use ZERO_PAGE instead.
> 
> Wait a second...
> 
> > -   sg_set_buf(_out[1], pad, sizeof pad);
> > +   sg_set_buf(_out[1], empty_zero_page, 16);
> 
> My fix here is obviously bogus (I meant to use ZERO_PAGE(0)), but what
> exactly is the code trying to do?  The old code makes no sense.  It's
> setting the *output* buffer to zeroed padding.

It's decrypting so I presume it just needs to the extra space for
the padding and the result will be thrown away.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH v2] keys/encrypted: Fix two crypto-on-the-stack bugs

2016-12-13 Thread Herbert Xu
On Tue, Dec 13, 2016 at 06:53:03PM -0800, Andy Lutomirski wrote:
> On Tue, Dec 13, 2016 at 6:48 PM, Andy Lutomirski  wrote:
> > The driver put a constant buffer of all zeros on the stack and
> > pointed a scatterlist entry at it in two places.  This doesn't work
> > with virtual stacks.  Use ZERO_PAGE instead.
> 
> Wait a second...
> 
> > -   sg_set_buf(_out[1], pad, sizeof pad);
> > +   sg_set_buf(_out[1], empty_zero_page, 16);
> 
> My fix here is obviously bogus (I meant to use ZERO_PAGE(0)), but what
> exactly is the code trying to do?  The old code makes no sense.  It's
> setting the *output* buffer to zeroed padding.

It's decrypting so I presume it just needs to the extra space for
the padding and the result will be thrown away.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: Remaining crypto API regressions with CONFIG_VMAP_STACK

2016-12-13 Thread Herbert Xu
On Tue, Dec 13, 2016 at 09:06:31AM -0800, Andy Lutomirski wrote:
>
> > Having 0 as type and CRYPTO_ALG_ASYNC as mask in general means
> > that we're requesting a sync algorithm (i.e., ASYNC bit off).
> >
> > However, it is completely unnecessary for shash as they can never
> > be async.  So this could be changed to just ("michael_mic", 0, 0).
> 
> I'm confused by a bunch of this.
> 
> 1. Is it really the case that crypto_alloc_xyz(..., CRYPTO_ALG_ASYNC)
> means to allocate a *synchronous* transform?  That's not what I
> expected.

crypto_alloc_xyz(name, 0, CRYPTO_ALG_ASYNC) allocates a sync tfm
and crypto_alloc_xyz(name, CRYPTO_ALG_ASYNC, CRYPTO_ALG_ASYNC)
allocates an async tfm while crypto_alloc_xyz(name, 0, 0) does
not care whether the allocated tfm is sync or asnc.

> 2. What guarantees that an async request is never allocated on the
> stack?  If it's just convention, could an assertion be added
> somewhere?

Sure we can add an assertion.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: Remaining crypto API regressions with CONFIG_VMAP_STACK

2016-12-13 Thread Herbert Xu
On Tue, Dec 13, 2016 at 09:06:31AM -0800, Andy Lutomirski wrote:
>
> > Having 0 as type and CRYPTO_ALG_ASYNC as mask in general means
> > that we're requesting a sync algorithm (i.e., ASYNC bit off).
> >
> > However, it is completely unnecessary for shash as they can never
> > be async.  So this could be changed to just ("michael_mic", 0, 0).
> 
> I'm confused by a bunch of this.
> 
> 1. Is it really the case that crypto_alloc_xyz(..., CRYPTO_ALG_ASYNC)
> means to allocate a *synchronous* transform?  That's not what I
> expected.

crypto_alloc_xyz(name, 0, CRYPTO_ALG_ASYNC) allocates a sync tfm
and crypto_alloc_xyz(name, CRYPTO_ALG_ASYNC, CRYPTO_ALG_ASYNC)
allocates an async tfm while crypto_alloc_xyz(name, 0, 0) does
not care whether the allocated tfm is sync or asnc.

> 2. What guarantees that an async request is never allocated on the
> stack?  If it's just convention, could an assertion be added
> somewhere?

Sure we can add an assertion.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] remoteproc: Remove firmware_loading_complete

2016-12-13 Thread kbuild test robot
Hi Sarangdhar,

[auto build test ERROR on next-20161213]
[also build test ERROR on v4.9]
[cannot apply to remoteproc/for-next v4.9-rc8 v4.9-rc7 v4.9-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Sarangdhar-Joshi/remoteproc-Remove-firmware_loading_complete/20161214-075027
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/soc/ti/wkup_m3_ipc.c: In function 'wkup_m3_rproc_boot_thread':
>> drivers/soc/ti/wkup_m3_ipc.c:373:36: error: 'struct rproc' has no member 
>> named 'firmware_loading_complete'
 wait_for_completion(_ipc->rproc->firmware_loading_complete);
   ^~

vim +373 drivers/soc/ti/wkup_m3_ipc.c

cdd5de50 Dave Gerlach 2015-09-22  367  
cdd5de50 Dave Gerlach 2015-09-22  368  static void 
wkup_m3_rproc_boot_thread(struct wkup_m3_ipc *m3_ipc)
cdd5de50 Dave Gerlach 2015-09-22  369  {
cdd5de50 Dave Gerlach 2015-09-22  370   struct device *dev = m3_ipc->dev;
cdd5de50 Dave Gerlach 2015-09-22  371   int ret;
cdd5de50 Dave Gerlach 2015-09-22  372  
cdd5de50 Dave Gerlach 2015-09-22 @373   
wait_for_completion(_ipc->rproc->firmware_loading_complete);
cdd5de50 Dave Gerlach 2015-09-22  374  
cdd5de50 Dave Gerlach 2015-09-22  375   init_completion(_ipc->sync_complete);
cdd5de50 Dave Gerlach 2015-09-22  376  

:: The code at line 373 was first introduced by commit
:: cdd5de500b2c90d5181ebc963826019a0a4234ba soc: ti: Add wkup_m3_ipc driver

:: TO: Dave Gerlach <d-gerl...@ti.com>
:: CC: Tony Lindgren <t...@atomide.com>

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] remoteproc: Remove firmware_loading_complete

2016-12-13 Thread kbuild test robot
Hi Sarangdhar,

[auto build test ERROR on next-20161213]
[also build test ERROR on v4.9]
[cannot apply to remoteproc/for-next v4.9-rc8 v4.9-rc7 v4.9-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Sarangdhar-Joshi/remoteproc-Remove-firmware_loading_complete/20161214-075027
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/soc/ti/wkup_m3_ipc.c: In function 'wkup_m3_rproc_boot_thread':
>> drivers/soc/ti/wkup_m3_ipc.c:373:36: error: 'struct rproc' has no member 
>> named 'firmware_loading_complete'
 wait_for_completion(_ipc->rproc->firmware_loading_complete);
   ^~

vim +373 drivers/soc/ti/wkup_m3_ipc.c

cdd5de50 Dave Gerlach 2015-09-22  367  
cdd5de50 Dave Gerlach 2015-09-22  368  static void 
wkup_m3_rproc_boot_thread(struct wkup_m3_ipc *m3_ipc)
cdd5de50 Dave Gerlach 2015-09-22  369  {
cdd5de50 Dave Gerlach 2015-09-22  370   struct device *dev = m3_ipc->dev;
cdd5de50 Dave Gerlach 2015-09-22  371   int ret;
cdd5de50 Dave Gerlach 2015-09-22  372  
cdd5de50 Dave Gerlach 2015-09-22 @373   
wait_for_completion(_ipc->rproc->firmware_loading_complete);
cdd5de50 Dave Gerlach 2015-09-22  374  
cdd5de50 Dave Gerlach 2015-09-22  375   init_completion(_ipc->sync_complete);
cdd5de50 Dave Gerlach 2015-09-22  376  

:: The code at line 373 was first introduced by commit
:: cdd5de500b2c90d5181ebc963826019a0a4234ba soc: ti: Add wkup_m3_ipc driver

:: TO: Dave Gerlach 
:: CC: Tony Lindgren 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[GIT PULL] Thermal management updates for v4.10-rc1

2016-12-13 Thread Zhang Rui
Hi, Linus,

Please pull from
  git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next

to receive the latest Thermal Management updates for v4.10-rc1 with
top-most commit 0faf7dd5a947006978b549dfe29a01b710becf4a:

  MAINTAINERS: Samsung: Update maintainer for PWM FAN and SAMSUNG
THERMAL (2016-12-13 11:20:23 +0800)

on top of commit 23400ac997062647f2b63c82030d189671b1effe:

  Merge branch 'for-rc' of
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux (2016-11-22
13:53:01 -0800)

Specifics:

- Thermal core code reorganization and cleanup. Two new files are
  created for thermal sysfs I/F code and thermal helper functions.
  From: Eduardo Valentin.

- Sanitize hotplug and locking for x86_pkg_temp driver.
  From: Thomas Gleixner.

- Update MAINTAINER file for pwm-fan driver and Samsung thermal driver.
  From: Lukasz Majewski.

- Fix module auto-load for max77620, tango and db8500 thermal driver.
  From: Javier Martinez Canillas.

- Fix a bug that thermal hwmon sysfs I/F returns wrong critical trip
  point temperature value. From: Krzysztof Kozlowski.

- Add Skylake PCH 100 series support for intel_pch_thermal driver.
  From: OGAWA Hirofumi.

- Small fixes and cleanups for platform thermal drivers.
  From Julia Lawall, Luis Henriques, Leo Yan, Stephen Boyd,
  Shawn Lin, Javi Merino and Lukasz Luba.

thanks,
rui


Eduardo Valentin (49):
  thermal: core: prevent zones with no types to be registered
  thermal: core: group thermal_zone DEVICE_ATTR's declarations
  thermal: core: group device_create_file() calls that are always
created
  thermal: core: use dev.groups to manage always present tz
attributes
  thermal: core: move emul_temp creation to tz->device.groups
  thermal: core: move mode attribute to tz->device.groups
  thermal: core: move passive attr to tz->device.groups
  thermal: core: improve power actor documentation
  thermal: core: move power actor code out of sysfs I/F section
  thermal: core: remove useless empty line
  thermal: core: fix style on remove_trip_attrs()
  thermal: core: move the trip attrs to the tz sysfs I/F section
  thermal: core: create tz->device.groups dynamically
  thermal: core: move trips attributes to tz->device.groups
  thermal: core: remove unnecessary device_remove() calls
  thermal: core: split passive_store
  thermal: core: split policy_store
  thermal: core: split available_policies_show()
  thermal: core: move to_thermal_zone() macro to header file
  thermal: core: treat correctly the return value of *scanf calls
  thermal: core: match parenthesis on code alignment
  thermal: core: move thermal_zone sysfs to thermal_sysfs.c
  thermal: core: move to_cooling_device macro to header file
  thermal: core: move cooling device sysfs to thermal_sysfs.c
  thermal: core: remove a couple of style issues on helpers
  thermal: core: introduce thermal_helpers.c
  thermal: core: group functions related to governor handling
  thermal: core: move idr handling to device management section
  thermal: core: small style fix on __unbind() helper
  thermal: core: move __unbind() helper to where it is used
  thermal: core: move bind_cdev() to where it is used
  thermal: core: move bind_tz() to where it is used
  thermal: core: fix couple of style issues on __bind() helper
  thermal: core: move __bind() to where it is used
  thermal: core: add inline to print_bind_err_msg()
  thermal: core: move notify to the zone update section
  thermal: core: add a comment describing the main update loop
  thermal: core: add a comment describing the power actor section
  thermal: core: add a comment describing the device management
section
  thermal: sysfs: remove symbols of emul_temp when config is
disabled
  thermal: core: remove FSF address in the GPL notice
  thermal: core: small style fix when checking for
__find_governor()
  thermal: core: standardize line breaking alignment
  thermal: core: remove void function return statements
  thermal: core: remove style warnings and checks
  thermal: core: improve kerneldoc entry of
thermal_cooling_device_unregister
  thermal: core: use kzalloc(sizeof(*ptr),...)
  thermal: sysfs: use kcalloc() instead of kzalloc()
  thermal: core: move slop and offset helpers to thermal_helpers.c

Javi Merino (1):
  devfreq_cooling: pass a pointer to devfreq in the power model
callbacks

Javier Martinez Canillas (3):
  thermal: max77620: Fix module autoload
  thermal: tango: Fix module autoload
  thermal: db8500: Fix module autoload

Julia Lawall (2):
  thermal: hwmon: use permission-specific DEVICE_ATTR variants
  thermal: int340x_thermal: use permission-specific DEVICE_ATTR
variants

Krzysztof Kozlowski (1):
  thermal: hwmon: Properly report critical temperature in sysfs


[GIT PULL] Thermal management updates for v4.10-rc1

2016-12-13 Thread Zhang Rui
Hi, Linus,

Please pull from
  git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next

to receive the latest Thermal Management updates for v4.10-rc1 with
top-most commit 0faf7dd5a947006978b549dfe29a01b710becf4a:

  MAINTAINERS: Samsung: Update maintainer for PWM FAN and SAMSUNG
THERMAL (2016-12-13 11:20:23 +0800)

on top of commit 23400ac997062647f2b63c82030d189671b1effe:

  Merge branch 'for-rc' of
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux (2016-11-22
13:53:01 -0800)

Specifics:

- Thermal core code reorganization and cleanup. Two new files are
  created for thermal sysfs I/F code and thermal helper functions.
  From: Eduardo Valentin.

- Sanitize hotplug and locking for x86_pkg_temp driver.
  From: Thomas Gleixner.

- Update MAINTAINER file for pwm-fan driver and Samsung thermal driver.
  From: Lukasz Majewski.

- Fix module auto-load for max77620, tango and db8500 thermal driver.
  From: Javier Martinez Canillas.

- Fix a bug that thermal hwmon sysfs I/F returns wrong critical trip
  point temperature value. From: Krzysztof Kozlowski.

- Add Skylake PCH 100 series support for intel_pch_thermal driver.
  From: OGAWA Hirofumi.

- Small fixes and cleanups for platform thermal drivers.
  From Julia Lawall, Luis Henriques, Leo Yan, Stephen Boyd,
  Shawn Lin, Javi Merino and Lukasz Luba.

thanks,
rui


Eduardo Valentin (49):
  thermal: core: prevent zones with no types to be registered
  thermal: core: group thermal_zone DEVICE_ATTR's declarations
  thermal: core: group device_create_file() calls that are always
created
  thermal: core: use dev.groups to manage always present tz
attributes
  thermal: core: move emul_temp creation to tz->device.groups
  thermal: core: move mode attribute to tz->device.groups
  thermal: core: move passive attr to tz->device.groups
  thermal: core: improve power actor documentation
  thermal: core: move power actor code out of sysfs I/F section
  thermal: core: remove useless empty line
  thermal: core: fix style on remove_trip_attrs()
  thermal: core: move the trip attrs to the tz sysfs I/F section
  thermal: core: create tz->device.groups dynamically
  thermal: core: move trips attributes to tz->device.groups
  thermal: core: remove unnecessary device_remove() calls
  thermal: core: split passive_store
  thermal: core: split policy_store
  thermal: core: split available_policies_show()
  thermal: core: move to_thermal_zone() macro to header file
  thermal: core: treat correctly the return value of *scanf calls
  thermal: core: match parenthesis on code alignment
  thermal: core: move thermal_zone sysfs to thermal_sysfs.c
  thermal: core: move to_cooling_device macro to header file
  thermal: core: move cooling device sysfs to thermal_sysfs.c
  thermal: core: remove a couple of style issues on helpers
  thermal: core: introduce thermal_helpers.c
  thermal: core: group functions related to governor handling
  thermal: core: move idr handling to device management section
  thermal: core: small style fix on __unbind() helper
  thermal: core: move __unbind() helper to where it is used
  thermal: core: move bind_cdev() to where it is used
  thermal: core: move bind_tz() to where it is used
  thermal: core: fix couple of style issues on __bind() helper
  thermal: core: move __bind() to where it is used
  thermal: core: add inline to print_bind_err_msg()
  thermal: core: move notify to the zone update section
  thermal: core: add a comment describing the main update loop
  thermal: core: add a comment describing the power actor section
  thermal: core: add a comment describing the device management
section
  thermal: sysfs: remove symbols of emul_temp when config is
disabled
  thermal: core: remove FSF address in the GPL notice
  thermal: core: small style fix when checking for
__find_governor()
  thermal: core: standardize line breaking alignment
  thermal: core: remove void function return statements
  thermal: core: remove style warnings and checks
  thermal: core: improve kerneldoc entry of
thermal_cooling_device_unregister
  thermal: core: use kzalloc(sizeof(*ptr),...)
  thermal: sysfs: use kcalloc() instead of kzalloc()
  thermal: core: move slop and offset helpers to thermal_helpers.c

Javi Merino (1):
  devfreq_cooling: pass a pointer to devfreq in the power model
callbacks

Javier Martinez Canillas (3):
  thermal: max77620: Fix module autoload
  thermal: tango: Fix module autoload
  thermal: db8500: Fix module autoload

Julia Lawall (2):
  thermal: hwmon: use permission-specific DEVICE_ATTR variants
  thermal: int340x_thermal: use permission-specific DEVICE_ATTR
variants

Krzysztof Kozlowski (1):
  thermal: hwmon: Properly report critical temperature in sysfs


linux-next: Tree for Dec 14

2016-12-13 Thread Stephen Rothwell
Hi all,

Please do not add any material for v4.11 to your linux-next included
branches until after v4.10-rc1 has been released.

Changes since 20161213:

The vfs-miklos tree gained a conflict against the ubifs tree.

The akpm-current tree gained a conflict against the jc_docs tree.

Non-merge commits (relative to Linus' tree): 4498
 4320 files changed, 189429 insertions(+), 94239 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(with KALLSYMS_EXTRA_PASS=1) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 245 trees (counting Linus' and 35 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (b92e09bb5bf4 Merge branch 'for-4.10' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata)
Merging fixes/master (30066ce675d3 Merge branch 'linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6)
Merging kbuild-current/rc-fixes (152b695d7437 builddeb: fix cross-building to 
arm64 producing host-arch debs)
Merging arc-current/for-curr (7badf6fefca8 ARC: axs10x: really enable ARC PGU)
Merging arm-current/fixes (8478132a8784 Revert "arm: move exports to 
definitions")
Merging m68k-current/for-linus (7e251bb21ae0 m68k: Fix ndelay() macro)
Merging metag-fixes/fixes (35d04077ad96 metag: Only define 
atomic_dec_if_positive conditionally)
Merging powerpc-fixes/fixes (dadc4a1bb9f0 powerpc/64: Fix placement of .text to 
be immediately following .head.text)
Merging sparc/master (8fa3b6f9392b Merge tag 'cris-for-4.10' of 
git://git.kernel.org/pub/scm/linux/kernel/git/jesper/cris)
Merging net/master (3e1ed981b7a9 netlink: revert broken, broken "2-clause 
nla_ok()")
Merging ipsec/master (bc3913a5378c Merge 
git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc)
Merging netfilter/master (a220871be66f virtio-net: correctly enable multiqueue)
Merging ipvs/master (045169816b31 Merge branch 'linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6)
Merging wireless-drivers/master (fcd2042e8d36 mwifiex: printk() overflow with 
32-byte SSIDs)
Merging mac80211/master (d8da0b5d64d5 mac80211: Ensure enough headroom when 
forwarding mesh pkt)
Merging sound-current/for-linus (995c6a7fd9b9 ALSA: hiface: Fix M2Tech hiFace 
driver sampling rate change)
Merging pci-current/for-linus (e42010d8207f PCI: Set Read Completion Boundary 
to 128 iff Root Port supports it (_HPX))
Merging driver-core.current/driver-core-linus (a25f0944ba9b Linux 4.9-rc5)
Merging tty.current/tty-linus (a909d3e63699 Linux 4.9-rc3)
Merging usb.current/usb-linus (e5517c2a5a49 Linux 4.9-rc7)
Merging usb-gadget-fixes/fixes (05e78c6933d6 usb: gadget: f_fs: fix wrong 
parenthesis in ffs_func_req_match())
Merging usb-serial-fixes/usb-linus (46490c347df4 USB: serial: option: add dlink 
dwm-158)
Merging usb-chipidea-fixes/ci-for-usb-stable (c7fbb09b2ea1 usb: chipidea: move 
the lock initialization to core file)
Merging phy/fixes (4320f9d4c183 phy: sun4i: check PMU presence when poking 
unknown bit of pmu)
Merging staging.current/staging-linus (a25f0944ba9b Linux 4.9-rc5)
Merging char-misc.current/char-misc-linus (a25f0944ba9b Linux 4.9-rc5)
Merging input-current/for-linus (2425f1808123 Input: change KEY_DATA from 0x275 
to 0x277)
Merging crypto-current/master (04b46fbdea5e crypto: testmgr - fix overlap in 
chunked tests again)
Merging ide/master (797cee982eef Merge branch 'stable-4.8' of 
git://git.infradead.org/users/pcm

linux-next: Tree for Dec 14

2016-12-13 Thread Stephen Rothwell
Hi all,

Please do not add any material for v4.11 to your linux-next included
branches until after v4.10-rc1 has been released.

Changes since 20161213:

The vfs-miklos tree gained a conflict against the ubifs tree.

The akpm-current tree gained a conflict against the jc_docs tree.

Non-merge commits (relative to Linus' tree): 4498
 4320 files changed, 189429 insertions(+), 94239 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(with KALLSYMS_EXTRA_PASS=1) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 245 trees (counting Linus' and 35 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (b92e09bb5bf4 Merge branch 'for-4.10' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata)
Merging fixes/master (30066ce675d3 Merge branch 'linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6)
Merging kbuild-current/rc-fixes (152b695d7437 builddeb: fix cross-building to 
arm64 producing host-arch debs)
Merging arc-current/for-curr (7badf6fefca8 ARC: axs10x: really enable ARC PGU)
Merging arm-current/fixes (8478132a8784 Revert "arm: move exports to 
definitions")
Merging m68k-current/for-linus (7e251bb21ae0 m68k: Fix ndelay() macro)
Merging metag-fixes/fixes (35d04077ad96 metag: Only define 
atomic_dec_if_positive conditionally)
Merging powerpc-fixes/fixes (dadc4a1bb9f0 powerpc/64: Fix placement of .text to 
be immediately following .head.text)
Merging sparc/master (8fa3b6f9392b Merge tag 'cris-for-4.10' of 
git://git.kernel.org/pub/scm/linux/kernel/git/jesper/cris)
Merging net/master (3e1ed981b7a9 netlink: revert broken, broken "2-clause 
nla_ok()")
Merging ipsec/master (bc3913a5378c Merge 
git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc)
Merging netfilter/master (a220871be66f virtio-net: correctly enable multiqueue)
Merging ipvs/master (045169816b31 Merge branch 'linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6)
Merging wireless-drivers/master (fcd2042e8d36 mwifiex: printk() overflow with 
32-byte SSIDs)
Merging mac80211/master (d8da0b5d64d5 mac80211: Ensure enough headroom when 
forwarding mesh pkt)
Merging sound-current/for-linus (995c6a7fd9b9 ALSA: hiface: Fix M2Tech hiFace 
driver sampling rate change)
Merging pci-current/for-linus (e42010d8207f PCI: Set Read Completion Boundary 
to 128 iff Root Port supports it (_HPX))
Merging driver-core.current/driver-core-linus (a25f0944ba9b Linux 4.9-rc5)
Merging tty.current/tty-linus (a909d3e63699 Linux 4.9-rc3)
Merging usb.current/usb-linus (e5517c2a5a49 Linux 4.9-rc7)
Merging usb-gadget-fixes/fixes (05e78c6933d6 usb: gadget: f_fs: fix wrong 
parenthesis in ffs_func_req_match())
Merging usb-serial-fixes/usb-linus (46490c347df4 USB: serial: option: add dlink 
dwm-158)
Merging usb-chipidea-fixes/ci-for-usb-stable (c7fbb09b2ea1 usb: chipidea: move 
the lock initialization to core file)
Merging phy/fixes (4320f9d4c183 phy: sun4i: check PMU presence when poking 
unknown bit of pmu)
Merging staging.current/staging-linus (a25f0944ba9b Linux 4.9-rc5)
Merging char-misc.current/char-misc-linus (a25f0944ba9b Linux 4.9-rc5)
Merging input-current/for-linus (2425f1808123 Input: change KEY_DATA from 0x275 
to 0x277)
Merging crypto-current/master (04b46fbdea5e crypto: testmgr - fix overlap in 
chunked tests again)
Merging ide/master (797cee982eef Merge branch 'stable-4.8' of 
git://git.infradead.org/users/pcm

Re: netlink: GPF in sock_sndtimeo

2016-12-13 Thread Richard Guy Briggs
On 2016-12-13 16:17, Cong Wang wrote:
> On Tue, Dec 13, 2016 at 2:52 AM, Richard Guy Briggs  wrote:
> > It is actually the audit_pid and audit_nlk_portid that I care about
> > more.  The audit daemon could vanish or close the socket while the
> > kernel sock to which it was attached is still quite valid.  Accessing
> > the set of three atomically is the urge.  I wonder if it makes more
> > sense to test for the presence of auditd using audit_sock rather than
> > audit_pid, but still keep audit_pid for our reporting and replacement
> > strategy.  Another idea would be to put the three in one struct.
> 
> Note, the process has audit_pid should hold a refcnt to the netns too,
> so the netns can't be gone until that process is gone.

I noted that.  I did wonder if there might be a problem if all the
processes were moved to another netns with the struct sock stuck in the
now process-void netns.

This is alluded-to in 6f285b19d09f ("audit: Send replies in the proper
network namespace.").

> > Can someone explain how they think the original test was able to trigger
> > this GPF?  Network namespace shutdown while something pretended to set
> > up a new auditd?  That's impressive for a fuzzer if that's the case...
> > Is there an strace?  I guess it is all in test().
> 
> I am surprised you still don't get the race condition even when you
> are now working on v2...
> 
> The race happens in this scenarios :
> 
> 1) Create a new netns
> 
> 2) In the new netns, communicate with kauditd to set audit_sock
> 
> 3) Generate some audit messages, so kauditd will keep sending them
> via audit_sock
> 
> 4) exit the netns
> 
> 5) the previous audit_sock is now going away, but kaudit_sock could still
> access it in this small window.

Ah ok that fits...

- RGB

--
Richard Guy Briggs 
Kernel Security Engineering, Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635


Re: netlink: GPF in sock_sndtimeo

2016-12-13 Thread Richard Guy Briggs
On 2016-12-13 16:17, Cong Wang wrote:
> On Tue, Dec 13, 2016 at 2:52 AM, Richard Guy Briggs  wrote:
> > It is actually the audit_pid and audit_nlk_portid that I care about
> > more.  The audit daemon could vanish or close the socket while the
> > kernel sock to which it was attached is still quite valid.  Accessing
> > the set of three atomically is the urge.  I wonder if it makes more
> > sense to test for the presence of auditd using audit_sock rather than
> > audit_pid, but still keep audit_pid for our reporting and replacement
> > strategy.  Another idea would be to put the three in one struct.
> 
> Note, the process has audit_pid should hold a refcnt to the netns too,
> so the netns can't be gone until that process is gone.

I noted that.  I did wonder if there might be a problem if all the
processes were moved to another netns with the struct sock stuck in the
now process-void netns.

This is alluded-to in 6f285b19d09f ("audit: Send replies in the proper
network namespace.").

> > Can someone explain how they think the original test was able to trigger
> > this GPF?  Network namespace shutdown while something pretended to set
> > up a new auditd?  That's impressive for a fuzzer if that's the case...
> > Is there an strace?  I guess it is all in test().
> 
> I am surprised you still don't get the race condition even when you
> are now working on v2...
> 
> The race happens in this scenarios :
> 
> 1) Create a new netns
> 
> 2) In the new netns, communicate with kauditd to set audit_sock
> 
> 3) Generate some audit messages, so kauditd will keep sending them
> via audit_sock
> 
> 4) exit the netns
> 
> 5) the previous audit_sock is now going away, but kaudit_sock could still
> access it in this small window.

Ah ok that fits...

- RGB

--
Richard Guy Briggs 
Kernel Security Engineering, Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635


Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error

2016-12-13 Thread Paul E. McKenney
On Wed, Dec 14, 2016 at 09:40:02AM +0800, Boqun Feng wrote:
> On Wed, Dec 14, 2016 at 08:47:55AM +0800, Boqun Feng wrote:
> > On Tue, Dec 13, 2016 at 10:36:47AM -0800, Paul E. McKenney wrote:
> > > On Wed, Dec 14, 2016 at 02:09:27AM +0800, Boqun Feng wrote:
> > > > 2016年12月14日 上午1:17,"Mark Rutland" 写道:
> > > > >
> > > > > Hi,
> > > > >
> > > > > On Tue, Dec 13, 2016 at 10:56:46AM +, Colin King wrote:
> > > > > > From: Colin Ian King 
> > > > > >
> > > > > > mask and bit are unsigned longs, so if bit is 31 we end up sign
> > > > > > extending the 1 and mask ends up as 0x8000. Fix this
> > > > > > by explicitly adding integer suffix UL ensure 1 is a unsigned long
> > > > > > rather than an signed int.
> > > > > >
> > > > > > Issue found with static analysis with CoverityScan, CID 1388564
> > > > > >
> > > > > > Fixes: 8965c3ce4718754db ("rcu: Use
> > > > leaf_node_for_each_mask_possible_cpu() in force_qs_rnp()")
> > > > > > Signed-off-by: Colin Ian King 
> > > > > > ---
> > > > > >  kernel/rcu/tree.c | 2 +-
> > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > > > > > index 10162ac..6ecedd8 100644
> > > > > > --- a/kernel/rcu/tree.c
> > > > > > +++ b/kernel/rcu/tree.c
> > > > > > @@ -3051,7 +3051,7 @@ static void force_qs_rnp(struct rcu_state 
> > > > > > *rsp,
> > > > > >
> > > > > >   leaf_node_for_each_mask_possible_cpu(rnp, rnp->qsmask,
> > > > bit, cpu)
> > > > > >   if (f(per_cpu_ptr(rsp->rda, cpu), isidle, 
> > > > > > maxj))
> > > > > > - mask |= 1 << bit;
> > > > > > + mask |= 1UL << bit;
> > > > >
> > > > > So as to match the rest of the code altered in commit bc75e99983df1efd
> > > > > ("rcu: Correctly handle sparse possible cpus"), and regardless of
> > > > > naming, I think it'd be nicer to use leaf_node_cpu_bit(), e.g.
> > > > >
> > > > > leaf_node_for_each_mask_possible_cpu(rnp, rnp->qsmask, bit, 
> > > > > cpu)
> > > > > if (f(per_cpu_ptr(rsp->rda, cpu), isidle, maxj))
> > > > > mask |= leaf_node_cpu_bit(rnp, cpu);
> > > > >
> > > > > IMO, it would be nice to hide the iterator bit somehow, to match
> > > > > for_each_leaf_node_possible_cpu(), which this largely looks similar to
> > > > > otherwise.
> > > > 
> > > > Good point. ;-)
> > > > 
> > > > We can
> > > > 
> > > > #define for_each_leaf_node_cpu(rnp, mask, cpu) \
> > > > for((cpu) = (rnp)->grplo + find _first_bit(mask, 
> > > > MASK_BITS(mask)); \
> > > > (cpu) >= (rnp)->grplo && (cpu) <= (rnp)->grphi; \
> > > > (cpu) = (rnp)->grplo + find _next_bit(mask, ...,
> > > > leaf_node_cpu_bit(rnp, cpu) + 1))) \
> > > > if (!cpu_possible(cpu)) \
> > > > continue; \
> > > > else
> > > 
> > > What is the purpose of the cpu_possible() check?
> > > 
> > 
> > To filter out CPUs in range [grplo, grphi] but not in cpu_possible_mask.
> > 
> 
> Hmm.. if rcu_cpu_starting(cpu) is never called with "impossible" cpu,
> IOW, ->qsmask and ->expmask never mask "impossible" cpus, then this is
> just an over-care check.
> 
> I think I probably will remove this check eventually, let me audit the
> code a little more for safety ;-)

Much better!  ;-)

Thanx, Paul

> Regards,
> Boqun
> 
> > Regards,
> > Boqun
> > 
> > >   Thanx, Paul
> > > 
> > > > Typing from my cellphone, plz ignore the bad formatting ;-)
> > > > 
> > > > Regards,
> > > > Boqun
> > > > 
> > > > > Thanks,
> > > > > Mark.
> > > 
> 
> 




Re: [PATCH 4.8 00/33] 4.8.15-stable review

2016-12-13 Thread Guenter Roeck

On 12/13/2016 09:16 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.8.15 release.
There are 33 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Thu Dec 15 17:15:24 UTC 2016.
Anything received after that time might be too late.



Build results:
total: 149 pass: 149 fail: 0
Qemu test results:
total: 122 pass: 122 fail: 0

Details are available at http://kerneltests.org/builders.

Guenter




  1   2   3   4   5   6   7   8   9   10   >