Re: [PATCH v4 4/5] mailbox: Add generic mechanism for testing Mailbox Controllers

2015-10-16 Thread kbuild test robot
Hi Lee,

[auto build test WARNING on v4.3-rc5 -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Lee-Jones/Mailbox-Provide-support-STi-based-platforms/20151016-152650
config: x86_64-allmodconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/mailbox/mailbox-test.c:225:36: sparse: incorrect type in argument 6 
(different address spaces)
   drivers/mailbox/mailbox-test.c:225:36:expected void const *buf
   drivers/mailbox/mailbox-test.c:225:36:got void [noderef] *mmio
   drivers/mailbox/mailbox-test.c:226:17: sparse: incorrect type in argument 2 
(different address spaces)
   drivers/mailbox/mailbox-test.c:226:17:expected void const *from
   drivers/mailbox/mailbox-test.c:226:17:got void [noderef] *mmio
   drivers/mailbox/mailbox-test.c:243:25: sparse: incorrect type in argument 1 
(different address spaces)
   drivers/mailbox/mailbox-test.c:243:25:expected void *to
   drivers/mailbox/mailbox-test.c:243:25:got void [noderef] *mmio
   drivers/mailbox/mailbox-test.c:245:25: sparse: incorrect type in argument 1 
(different address spaces)
   drivers/mailbox/mailbox-test.c:245:25:expected void *to
   drivers/mailbox/mailbox-test.c:245:25:got void [noderef] *mmio
   drivers/mailbox/mailbox-test.c: In function 'mbox_test_signal_write':
>> drivers/mailbox/mailbox-test.c:56:4: warning: format '%d' expects argument 
>> of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' 
>> [-Wformat=]
   "Signal length %d greater than max allowed %d\n",
   ^
   drivers/mailbox/mailbox-test.c: In function 'mbox_test_message_write':
   drivers/mailbox/mailbox-test.c:95:4: warning: format '%d' expects argument 
of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' 
[-Wformat=]
   "Message length %d greater than max allowed %d\n",
   ^

sparse warnings: (new ones prefixed by >>)

>> drivers/mailbox/mailbox-test.c:225:36: sparse: incorrect type in argument 6 
>> (different address spaces)
   drivers/mailbox/mailbox-test.c:225:36:expected void const *buf
   drivers/mailbox/mailbox-test.c:225:36:got void [noderef] *mmio
>> drivers/mailbox/mailbox-test.c:226:17: sparse: incorrect type in argument 2 
>> (different address spaces)
   drivers/mailbox/mailbox-test.c:226:17:expected void const *from
   drivers/mailbox/mailbox-test.c:226:17:got void [noderef] *mmio
>> drivers/mailbox/mailbox-test.c:243:25: sparse: incorrect type in argument 1 
>> (different address spaces)
   drivers/mailbox/mailbox-test.c:243:25:expected void *to
   drivers/mailbox/mailbox-test.c:243:25:got void [noderef] *mmio
   drivers/mailbox/mailbox-test.c:245:25: sparse: incorrect type in argument 1 
(different address spaces)
   drivers/mailbox/mailbox-test.c:245:25:expected void *to
   drivers/mailbox/mailbox-test.c:245:25:got void [noderef] *mmio
   drivers/mailbox/mailbox-test.c: In function 'mbox_test_signal_write':
   drivers/mailbox/mailbox-test.c:56:4: warning: format '%d' expects argument 
of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' 
[-Wformat=]
   "Signal length %d greater than max allowed %d\n",
   ^
   drivers/mailbox/mailbox-test.c: In function 'mbox_test_message_write':
   drivers/mailbox/mailbox-test.c:95:4: warning: format '%d' expects argument 
of type 'int', but argument 3 has type 'size_t {aka long unsigned int}' 
[-Wformat=]
   "Message length %d greater than max allowed %d\n",
   ^

vim +56 drivers/mailbox/mailbox-test.c

50  dev_err(tdev->dev, "Channel cannot do Tx\n");
51  return -EINVAL;
52  }
53  
54  if (count > MBOX_MAX_SIG_LEN) {
55  dev_err(tdev->dev,
  > 56  "Signal length %d greater than max allowed 
%d\n",
57  count, MBOX_MAX_SIG_LEN);
58  return -EINVAL;
59  }
60  
61  tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
62  if (!tdev->signal)
63  return -ENOMEM;
64  
65  ret = copy_from_user(tdev->signal, userbuf, count);
66  if (ret) {
67  kfree(tdev->signal);
68  return -EFAULT;
69  }
70  
71  return ret < 0 ? ret : count;
72  }
73  
74  static const struct file_operations mbox_test_signal_ops = {
75  .write  = mbox_test_signal_write,
76  .open   = simple_open,
77  .llseek = generic_file_llseek,
78  };
79  
80  static ssize_t mbox_test_message_write(struct file *filp,
81 const char __user *userbuf,
82 size_t count, 

[PATCH v4 4/5] mailbox: Add generic mechanism for testing Mailbox Controllers

2015-10-16 Thread Lee Jones
This particular Client implementation uses shared memory in order
to pass messages between Mailbox users; however, it can be easily
hacked to support any type of Controller.

Signed-off-by: Lee Jones 
---
 drivers/mailbox/Kconfig|   7 +
 drivers/mailbox/Makefile   |   2 +
 drivers/mailbox/mailbox-test.c | 361 +
 3 files changed, 370 insertions(+)
 create mode 100644 drivers/mailbox/mailbox-test.c

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 7b53386..546d05f 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -78,4 +78,11 @@ config STI_MBOX
  Mailbox implementation for STMicroelectonics family chips with
  hardware for interprocessor communication.
 
+config MAILBOX_TEST
+   tristate "Mailbox Test Client"
+   depends on OF
+   help
+ Test client to help with testing new Controller driver
+ implementations.
+
 endif
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 7cb4766..92435ef 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -2,6 +2,8 @@
 
 obj-$(CONFIG_MAILBOX)  += mailbox.o
 
+obj-$(CONFIG_MAILBOX_TEST) += mailbox-test.o
+
 obj-$(CONFIG_ARM_MHU)  += arm_mhu.o
 
 obj-$(CONFIG_PL320_MBOX)   += pl320-ipc.o
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
new file mode 100644
index 000..cac1ba2
--- /dev/null
+++ b/drivers/mailbox/mailbox-test.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright (C) 2015 ST Microelectronics
+ *
+ * Author: Lee Jones 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MBOX_MAX_SIG_LEN   8
+#define MBOX_MAX_MSG_LEN   128
+#define MBOX_BYTES_PER_LINE16
+#define MBOX_HEXDUMP_LINE_LEN  ((MBOX_BYTES_PER_LINE * 4) + 2)
+#define MBOX_HEXDUMP_MAX_LEN   (MBOX_HEXDUMP_LINE_LEN *\
+(MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE))
+
+static struct dentry *root_debugfs_dir;
+
+struct mbox_test_device {
+   struct device   *dev;
+   void __iomem*mmio;
+   struct mbox_chan*tx_channel;
+   struct mbox_chan*rx_channel;
+   char*rx_buffer;
+   char*signal;
+   char*message;
+   spinlock_t  lock;
+};
+
+static ssize_t mbox_test_signal_write(struct file *filp,
+  const char __user *userbuf,
+  size_t count, loff_t *ppos)
+{
+   struct mbox_test_device *tdev = filp->private_data;
+   int ret;
+
+   if (!tdev->tx_channel) {
+   dev_err(tdev->dev, "Channel cannot do Tx\n");
+   return -EINVAL;
+   }
+
+   if (count > MBOX_MAX_SIG_LEN) {
+   dev_err(tdev->dev,
+   "Signal length %d greater than max allowed %d\n",
+   count, MBOX_MAX_SIG_LEN);
+   return -EINVAL;
+   }
+
+   tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
+   if (!tdev->signal)
+   return -ENOMEM;
+
+   ret = copy_from_user(tdev->signal, userbuf, count);
+   if (ret) {
+   kfree(tdev->signal);
+   return -EFAULT;
+   }
+
+   return ret < 0 ? ret : count;
+}
+
+static const struct file_operations mbox_test_signal_ops = {
+   .write  = mbox_test_signal_write,
+   .open   = simple_open,
+   .llseek = generic_file_llseek,
+};
+
+static ssize_t mbox_test_message_write(struct file *filp,
+  const char __user *userbuf,
+  size_t count, loff_t *ppos)
+{
+   struct mbox_test_device *tdev = filp->private_data;
+   void *data;
+   int ret;
+
+   if (!tdev->tx_channel) {
+   dev_err(tdev->dev, "Channel cannot do Tx\n");
+   return -EINVAL;
+   }
+
+   if (count > MBOX_MAX_MSG_LEN) {
+   dev_err(tdev->dev,
+   "Message length %d greater than max allowed %d\n",
+   count, MBOX_MAX_MSG_LEN);
+   return -EINVAL;
+   }
+
+   tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
+   if (!tdev->message)
+   return -ENOMEM;
+
+   ret = copy_from_user(tdev->message, userbuf, count);
+   if (ret) {
+   ret = -EFAULT;
+   goto out;
+   }
+
+   /*
+* A separate signal is only of use if there is
+* MMIO to subsequently pass the message through
+*/
+   if (tdev->mmio && tdev->signal) {
+   print_

[PATCH v4 4/5] mailbox: Add generic mechanism for testing Mailbox Controllers

2015-10-05 Thread Lee Jones
This particular Client implementation uses shared memory in order
to pass messages between Mailbox users; however, it can be easily
hacked to support any type of Controller.

Signed-off-by: Lee Jones 
---
 drivers/mailbox/Kconfig|   7 +
 drivers/mailbox/Makefile   |   2 +
 drivers/mailbox/mailbox-test.c | 361 +
 3 files changed, 370 insertions(+)
 create mode 100644 drivers/mailbox/mailbox-test.c

diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 2cc4c39..7720bde 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -77,4 +77,11 @@ config STI_MBOX
  Mailbox implementation for STMicroelectonics family chips with
  hardware for interprocessor communication.
 
+config MAILBOX_TEST
+   tristate "Mailbox Test Client"
+   depends on OF
+   help
+ Test client to help with testing new Controller driver
+ implementations.
+
 endif
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 7cb4766..92435ef 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -2,6 +2,8 @@
 
 obj-$(CONFIG_MAILBOX)  += mailbox.o
 
+obj-$(CONFIG_MAILBOX_TEST) += mailbox-test.o
+
 obj-$(CONFIG_ARM_MHU)  += arm_mhu.o
 
 obj-$(CONFIG_PL320_MBOX)   += pl320-ipc.o
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
new file mode 100644
index 000..cac1ba2
--- /dev/null
+++ b/drivers/mailbox/mailbox-test.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright (C) 2015 ST Microelectronics
+ *
+ * Author: Lee Jones 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MBOX_MAX_SIG_LEN   8
+#define MBOX_MAX_MSG_LEN   128
+#define MBOX_BYTES_PER_LINE16
+#define MBOX_HEXDUMP_LINE_LEN  ((MBOX_BYTES_PER_LINE * 4) + 2)
+#define MBOX_HEXDUMP_MAX_LEN   (MBOX_HEXDUMP_LINE_LEN *\
+(MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE))
+
+static struct dentry *root_debugfs_dir;
+
+struct mbox_test_device {
+   struct device   *dev;
+   void __iomem*mmio;
+   struct mbox_chan*tx_channel;
+   struct mbox_chan*rx_channel;
+   char*rx_buffer;
+   char*signal;
+   char*message;
+   spinlock_t  lock;
+};
+
+static ssize_t mbox_test_signal_write(struct file *filp,
+  const char __user *userbuf,
+  size_t count, loff_t *ppos)
+{
+   struct mbox_test_device *tdev = filp->private_data;
+   int ret;
+
+   if (!tdev->tx_channel) {
+   dev_err(tdev->dev, "Channel cannot do Tx\n");
+   return -EINVAL;
+   }
+
+   if (count > MBOX_MAX_SIG_LEN) {
+   dev_err(tdev->dev,
+   "Signal length %d greater than max allowed %d\n",
+   count, MBOX_MAX_SIG_LEN);
+   return -EINVAL;
+   }
+
+   tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
+   if (!tdev->signal)
+   return -ENOMEM;
+
+   ret = copy_from_user(tdev->signal, userbuf, count);
+   if (ret) {
+   kfree(tdev->signal);
+   return -EFAULT;
+   }
+
+   return ret < 0 ? ret : count;
+}
+
+static const struct file_operations mbox_test_signal_ops = {
+   .write  = mbox_test_signal_write,
+   .open   = simple_open,
+   .llseek = generic_file_llseek,
+};
+
+static ssize_t mbox_test_message_write(struct file *filp,
+  const char __user *userbuf,
+  size_t count, loff_t *ppos)
+{
+   struct mbox_test_device *tdev = filp->private_data;
+   void *data;
+   int ret;
+
+   if (!tdev->tx_channel) {
+   dev_err(tdev->dev, "Channel cannot do Tx\n");
+   return -EINVAL;
+   }
+
+   if (count > MBOX_MAX_MSG_LEN) {
+   dev_err(tdev->dev,
+   "Message length %d greater than max allowed %d\n",
+   count, MBOX_MAX_MSG_LEN);
+   return -EINVAL;
+   }
+
+   tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
+   if (!tdev->message)
+   return -ENOMEM;
+
+   ret = copy_from_user(tdev->message, userbuf, count);
+   if (ret) {
+   ret = -EFAULT;
+   goto out;
+   }
+
+   /*
+* A separate signal is only of use if there is
+* MMIO to subsequently pass the message through
+*/
+   if (tdev->mmio && tdev->signal) {
+   print_