Skip to contentSkip to conversation

Mailbox: Provide support STi based platforms

PATCH RESEND Superseded Lee Jones 3 participants 10 messages Oct 16, 2015 – Oct 17, 2015

Subsystems (2)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

cover Mailbox: Provide support STi based platforms

Hi Jassi,

[Resending the updated patch-set this time]

This should be it. Exciting times!

ST's platforms currently support a maximum of 5 Mailboxes, one for each of the supported co-processors situated on the platform. Each Mailbox is divided up into 4 instances which consist of 32 channels. Messages are passed between the application and co-processors using shared memory areas.

Also included in the set is an example Client which should be generic enough to use as a testing environment for all Mailbox IPs which use shared memory or the API to pass messages. With small changes, it should also be able to test more extravagant implementations.

v3 -> v4:
- More protection in MBOX_BASE() MACRO
- Remove unused tx-only marker

v2 => v3:
- Controller
- Shared (DT <=> Device Driver) defines removed
- Return actual error codes instead of NULL in xlate()
- Not passing 'direction' configuration via DT anymore
- Removed all accompanying configuration checking code
- Test F/W
- Allow Rx-only and Tx-only controllers to be tested
- Cater for controllers requiring pre-Tx 'signal' to be sent
- Supply 'wr-' message debugfs file
- When written to, will Tx message through Mailbox Framework
- When read from, will print out a hexdump of Rx'ed message

v1 => v2:
- New MACRO() to obtain base address for a given instance
- Move locking into the structure it protects
- Stop checking for 'ready' state when sending data
- Don't clear channel data (that belongs to the API)
- #define register offsets instead of providing via pdata
- Register driver with module_platform_driver()

Lee Jones (5):
mailbox: dt: Supply bindings for ST's Mailbox IP
mailbox: Add support for ST's Mailbox IP
ARM: STi: stih407-family: Add nodes for Mailbox
mailbox: Add generic mechanism for testing Mailbox Controllers
ARM: STi: DT: STiH407: Enable Mailbox testing facility

 .../devicetree/bindings/mailbox/sti-mailbox.txt    |  51 ++
 arch/arm/boot/dts/stih407-family.dtsi              |  39 ++
 drivers/mailbox/Kconfig                            |  14 +
 drivers/mailbox/Makefile                           |   4 +
 drivers/mailbox/mailbox-sti.c                      | 513 +++++++++++++++++++++
 drivers/mailbox/mailbox-test.c                     | 361 +++++++++++++++
 6 files changed, 982 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/sti-mailbox.txt
 create mode 100644 drivers/mailbox/mailbox-sti.c
 create mode 100644 drivers/mailbox/mailbox-test.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v4 1/5 mailbox: dt: Supply bindings for ST's Mailbox IP

---
 .../devicetree/bindings/mailbox/sti-mailbox.txt    | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/sti-mailbox.txt
Documentation/devicetree/bindings/mailbox/sti-mailbox.txt new file +51 -0
new file mode 100644
index 0000000..b61eec9
@@ -0,0 +1,51 @@
+ST Microelectronics Mailbox Driver
+
+Each ST Mailbox IP currently consists of 4 instances of 32 channels.  Messages
+are passed between Application and Remote processors using shared memory.
+
+Controller
+----------
+
+Required properties:
+- compatible		: Should be "st,stih407-mailbox"
+- reg			: Offset and length of the device's register set
+- mbox-name		: Name of the mailbox
+- #mbox-cells:		: Must be 2
+			  <&phandle instance channel direction>
+			    phandle   : Label name of controller
+			    instance  : Instance number
+			    channel   : Channel number
+
+Optional properties
+- interrupts		: Contains the IRQ line for a Rx mailbox
+
+Example:
+
+mailbox0: mailbox at 0  {
+	compatible	= "st,stih407-mailbox";
+	reg		= <0x08f00000 0x1000>;
+	interrupts	= <GIC_SPI 1 IRQ_TYPE_NONE>;
+	#mbox-cells	= <2>;
+	mbox-name	= "a9";
+};
+
+Client
+------
+
+Required properties:
+- compatible		: Many (See the client docs)
+- reg			: Shared (between Application and Remote) memory address
+- mboxes		: Standard property to specify a Mailbox (See ./mailbox.txt)
+			  Cells must match 'mbox-cells' (See Controller docs above)
+
+Optional properties
+- mbox-names		: Name given to channels seen in the 'mboxes' property.
+
+Example:
+
+mailbox_test {
+	compatible	= "mailbox_test";
+	reg		= <0x[shared_memory_address], [shared_memory_size]>;
+	mboxes		= <&mailbox2 0 1>, <&mailbox0 2 1>;
+	mbox-names	= "tx",	"rx";
+};
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v4 2/5 mailbox: Add support for ST's Mailbox IP

In reply to Lee Jones

ST's platforms currently support a maximum of 5 Mailboxes, one for each of the supported co-processors situated on the platform. Each Mailbox is divided up into 4 instances which consist of 32 channels. Messages are passed between the application and co-processors using shared memory areas. It is the Client's responsibility to manage these areas.

---
 drivers/mailbox/Kconfig       |   7 +
 drivers/mailbox/Makefile      |   2 +
 drivers/mailbox/mailbox-sti.c | 513 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 522 insertions(+)
 create mode 100644 drivers/mailbox/mailbox-sti.c
drivers/mailbox/Kconfig +7 -0
index bbec500..7b53386 100644
@@ -71,4 +71,11 @@ config BCM2835_MBOX
 	  the services of the Videocore. Say Y here if you want to use the
 	  BCM2835 Mailbox.
 
+config STI_MBOX
+	tristate "STI Mailbox framework support"
+	depends on ARCH_STI && OF
+	help
+	  Mailbox implementation for STMicroelectonics family chips with
+	  hardware for interprocessor communication.
+
 endif
drivers/mailbox/Makefile +2 -0
index 8e6d822..7cb4766 100644
@@ -13,3 +13,5 @@ obj-$(CONFIG_PCC)		+= pcc.o
 obj-$(CONFIG_ALTERA_MBOX)	+= mailbox-altera.o
 
 obj-$(CONFIG_BCM2835_MBOX)	+= bcm2835-mailbox.o
+
+obj-$(CONFIG_STI_MBOX)		+= mailbox-sti.o
drivers/mailbox/mailbox-sti.c new file +513 -0

513 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#3 lore raw

PATCH v4 3/5 ARM: STi: stih407-family: Add nodes for Mailbox

In reply to Lee Jones

This patch supplies the Mailbox Controller nodes. In order to request channels, these nodes will be referenced by Mailbox Client nodes.

---
 arch/arm/boot/dts/stih407-family.dtsi | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/boot/dts/stih407-family.dtsi +33 -0
index ae05277..0e5d3ea 100644
@@ -610,5 +610,38 @@
 			clocks		= <&clk_sysin>;
 			st,pwm-num-chan = <4>;
 		};
+
+		mailbox0: mailbox at 0  {
+			compatible	= "st,stih407-mailbox";
+			reg		= <0x8f00000 0x1000>;
+			interrupts	= <GIC_SPI 1 IRQ_TYPE_NONE>;
+			#mbox-cells	= <2>;
+			mbox-name	= "a9";
+			status		= "okay";
+		};
+
+		mailbox1: mailbox at 1 {
+			compatible	= "st,stih407-mailbox";
+			reg		= <0x8f01000 0x1000>;
+			#mbox-cells	= <2>;
+			mbox-name	= "st231_gp_1";
+			status		= "okay";
+		};
+
+		mailbox2: mailbox at 2 {
+			compatible	= "st,stih407-mailbox";
+			reg		= <0x8f02000 0x1000>;
+			#mbox-cells	= <2>;
+			mbox-name	= "st231_gp_0";
+			status		= "okay";
+		};
+
+		mailbox3: mailbox at 3 {
+			compatible	= "st,stih407-mailbox";
+			reg		= <0x8f03000 0x1000>;
+			#mbox-cells	= <2>;
+			mbox-name	= "st231_audio_video";
+			status		= "okay";
+		};
 	};
 };
Signature · 1 line
1.9.1
author
#4 lore raw

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

In reply to 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.

---
 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
drivers/mailbox/Kconfig +7 -0
index 7b53386..546d05f 100644
@@ -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
drivers/mailbox/Makefile +2 -0
index 7cb4766..92435ef 100644
@@ -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
drivers/mailbox/mailbox-test.c new file +361 -0

361 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

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

reproduce:

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] <asn:2>*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] <asn:2>*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] <asn:2>*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] <asn:2>*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] <asn:2>*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] <asn:2>*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] <asn:2>*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] <asn:2>*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, loff_t *ppos)
    83	{
    84		struct mbox_test_device *tdev = filp->private_data;
    85		void *data;
    86		int ret;
    87	
    88		if (!tdev->tx_channel) {
    89			dev_err(tdev->dev, "Channel cannot do Tx\n");
    90			return -EINVAL;
    91		}
    92	
    93		if (count > MBOX_MAX_MSG_LEN) {
    94			dev_err(tdev->dev,
    95				"Message length %d greater than max allowed %d\n",
    96				count, MBOX_MAX_MSG_LEN);
    97			return -EINVAL;
    98		}
    99	
   100		tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
   101		if (!tdev->message)
   102			return -ENOMEM;
   103	
   104		ret = copy_from_user(tdev->message, userbuf, count);
   105		if (ret) {
   106			ret = -EFAULT;
   107			goto out;
   108		}
   109	
   110		/*
   111		 * A separate signal is only of use if there is
   112		 * MMIO to subsequently pass the message through
   113		 */
   114		if (tdev->mmio && tdev->signal) {
   115			print_hex_dump(KERN_INFO, "Client: Sending: Signal: ", DUMP_PREFIX_ADDRESS,
   116				       MBOX_BYTES_PER_LINE, 1, tdev->signal, MBOX_MAX_SIG_LEN, true);
   117	
   118			data = tdev->signal;
   119		} else
   120			data = tdev->message;
   121	
   122		print_hex_dump(KERN_INFO, "Client: Sending: Message: ", DUMP_PREFIX_ADDRESS,
   123			       MBOX_BYTES_PER_LINE, 1, tdev->message, MBOX_MAX_MSG_LEN, true);
   124	
   125		ret = mbox_send_message(tdev->tx_channel, data);
   126		if (ret < 0)
   127			dev_err(tdev->dev, "Failed to send message via mailbox\n");
   128	
   129	out:
   130		kfree(tdev->signal);
   131		kfree(tdev->message);
   132	
   133		return ret < 0 ? ret : count;
   134	}
   135	
   136	static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
   137					      size_t count, loff_t *ppos)
   138	{
   139		struct mbox_test_device *tdev = filp->private_data;
   140		unsigned long flags;
   141		char *touser, *ptr;
   142		int l = 0;
   143		int ret;
   144	
   145		touser = kzalloc(MBOX_HEXDUMP_MAX_LEN, GFP_KERNEL);
   146		if (!touser)
   147			return -ENOMEM;
   148	
   149		if (!tdev->rx_channel) {
   150			ret = snprintf(touser, 20, "<NO RX CAPABILITY>\n");
   151			ret = simple_read_from_buffer(userbuf, count, ppos,
   152						      touser, ret);
   153			goto out;
   154		}
   155	
   156		if (tdev->rx_buffer[0] == '\0') {
   157			ret = snprintf(touser, 9, "<EMPTY>\n");
   158			ret = simple_read_from_buffer(userbuf, count, ppos,
   159						      touser, ret);
   160			goto out;
   161		}
   162	
   163		spin_lock_irqsave(&tdev->lock, flags);
   164	
   165		ptr = tdev->rx_buffer;
   166		while (l < MBOX_HEXDUMP_MAX_LEN) {
   167			hex_dump_to_buffer(ptr,
   168					   MBOX_BYTES_PER_LINE,
   169					   MBOX_BYTES_PER_LINE, 1, touser + l,
   170					   MBOX_HEXDUMP_LINE_LEN, true);
   171	
   172			ptr += MBOX_BYTES_PER_LINE;
   173			l += MBOX_HEXDUMP_LINE_LEN;
   174			*(touser + (l - 1)) = '\n';
   175		}
   176		*(touser + l) = '\0';
   177	
   178		memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN);
   179	
   180		spin_unlock_irqrestore(&tdev->lock, flags);
   181	
   182		ret = simple_read_from_buffer(userbuf, count, ppos, touser, MBOX_HEXDUMP_MAX_LEN);
   183	out:
   184		kfree(touser);
   185		return ret;
   186	}
   187	
   188	static const struct file_operations mbox_test_message_ops = {
   189		.write	= mbox_test_message_write,
   190		.read	= mbox_test_message_read,
   191		.open	= simple_open,
   192		.llseek	= generic_file_llseek,
   193	};
   194	
   195	static int mbox_test_add_debugfs(struct platform_device *pdev,
   196					 struct mbox_test_device *tdev)
   197	{
   198		if (!debugfs_initialized())
   199			return 0;
   200	
   201		root_debugfs_dir = debugfs_create_dir("mailbox", NULL);
   202		if (!root_debugfs_dir) {
   203			dev_err(&pdev->dev, "Failed to create Mailbox debugfs\n");
   204			return -EINVAL;
   205		}
   206	
   207		debugfs_create_file("message", 0600, root_debugfs_dir,
   208				    tdev, &mbox_test_message_ops);
   209	
   210		debugfs_create_file("signal", 0200, root_debugfs_dir,
   211				    tdev, &mbox_test_signal_ops);
   212	
   213		return 0;
   214	}
   215	
   216	static void mbox_test_receive_message(struct mbox_client *client, void *message)
   217	{
   218		struct mbox_test_device *tdev = dev_get_drvdata(client->dev);
   219		unsigned long flags;
   220	
   221		spin_lock_irqsave(&tdev->lock, flags);
   222		if (tdev->mmio) {
   223			print_hex_dump(KERN_INFO, "Client: Received [MMIO]: ",
   224				       DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1,
 > 225				       tdev->mmio, MBOX_MAX_MSG_LEN, true);
 > 226			memcpy(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN);
   227	
   228		} else if (message) {
   229			print_hex_dump(KERN_INFO, "Client: Received [API]: ",
   230				       DUMP_PREFIX_ADDRESS, MBOX_BYTES_PER_LINE, 1,
   231				       message, MBOX_MAX_MSG_LEN, true);
   232			memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN);
   233		}
   234		spin_unlock_irqrestore(&tdev->lock, flags);
   235	}
   236	
   237	static void mbox_test_prepare_message(struct mbox_client *client, void *message)
   238	{
   239		struct mbox_test_device *tdev = dev_get_drvdata(client->dev);
   240	
   241		if (tdev->mmio) {
   242			if (tdev->signal)
 > 243				memcpy(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN);

244 else
245 memcpy(tdev->mmio, message, MBOX_MAX_MSG_LEN);
246 }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 50056 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151016/cde8a178/attachment-0001.obj>

author
#6 lore raw

PATCH 1/1 mailbox: Fix a couple of trivial static checker issues

mailbox: Fix a couple of trivial static checker issues

This patch deals with a few spelling, white space and type warnings reported by Intel's Kbuild Test Robot.

---
 drivers/mailbox/mailbox-sti.c  |  2 +-
 drivers/mailbox/mailbox-test.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/mailbox/mailbox-sti.c +1 -1
index f11d4e8..4835817 100644
@@ -64,7 +64,7 @@ struct sti_mbox_device {
 };
 
 /**
- * STi Mailbox platform specfic configuration
+ * STi Mailbox platform specific configuration
  *
  * @num_inst:	Maximum number of instances in one HW Mailbox
  * @num_chan:	Maximum number of channel per instance
drivers/mailbox/mailbox-test.c +5 -5
index cac1ba2..196144c 100644
@@ -22,7 +22,7 @@
 #define MBOX_MAX_SIG_LEN	8
 #define MBOX_MAX_MSG_LEN	128
 #define MBOX_BYTES_PER_LINE	16
-#define MBOX_HEXDUMP_LINE_LEN 	((MBOX_BYTES_PER_LINE * 4) + 2)
+#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))
 
@@ -30,7 +30,7 @@ static struct dentry *root_debugfs_dir;
 
 struct mbox_test_device {
 	struct device		*dev;
-	void __iomem		*mmio;
+	void			*mmio;
 	struct mbox_chan	*tx_channel;
 	struct mbox_chan	*rx_channel;
 	char			*rx_buffer;
@@ -53,7 +53,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
 
 	if (count > MBOX_MAX_SIG_LEN) {
 		dev_err(tdev->dev,
-			"Signal length %d greater than max allowed %d\n",
+			"Signal length %lu greater than max allowed %d\n",
 			count, MBOX_MAX_SIG_LEN);
 		return -EINVAL;
 	}
@@ -92,7 +92,7 @@ static ssize_t mbox_test_message_write(struct file *filp,
 
 	if (count > MBOX_MAX_MSG_LEN) {
 		dev_err(tdev->dev,
-			"Message length %d greater than max allowed %d\n",
+			"Message length %lu greater than max allowed %d\n",
 			count, MBOX_MAX_MSG_LEN);
 		return -EINVAL;
 	}
@@ -303,7 +303,7 @@ static int mbox_test_probe(struct platform_device *pdev)
 	tdev->tx_channel = mbox_test_request_channel(pdev, "tx");
 	tdev->rx_channel = mbox_test_request_channel(pdev, "rx");
 
-	if (!tdev->tx_channel && !tdev->tx_channel)
+	if (!tdev->tx_channel && !tdev->rx_channel)
 		return -EPROBE_DEFER;
 
 	tdev->dev = &pdev->dev;
author
#7 lore raw

PATCH v2 1/1 mailbox: Fix a couple of trivial static checker issues

mailbox: Fix a couple of trivial static checker issues

This patch deals with a few spelling, white space and type warnings reported by Intel's Kbuild Test Robot.

---
v1 => v2:

Looks like I took the AKA in this too literally:

format '%d' expects argument of type 'int',
but argument 3 has type 'size_t {aka long unsigned int}'

After some research I found a new printk format specifier suitable for size_t.

 drivers/mailbox/mailbox-sti.c  |  2 +-
 drivers/mailbox/mailbox-test.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/mailbox/mailbox-sti.c +1 -1
index f11d4e8..4835817 100644
@@ -64,7 +64,7 @@ struct sti_mbox_device {
 };
 
 /**
- * STi Mailbox platform specfic configuration
+ * STi Mailbox platform specific configuration
  *
  * @num_inst:	Maximum number of instances in one HW Mailbox
  * @num_chan:	Maximum number of channel per instance
drivers/mailbox/mailbox-test.c +5 -5
index cac1ba2..22f2e40 100644
@@ -22,7 +22,7 @@
 #define MBOX_MAX_SIG_LEN	8
 #define MBOX_MAX_MSG_LEN	128
 #define MBOX_BYTES_PER_LINE	16
-#define MBOX_HEXDUMP_LINE_LEN 	((MBOX_BYTES_PER_LINE * 4) + 2)
+#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))
 
@@ -30,7 +30,7 @@ static struct dentry *root_debugfs_dir;
 
 struct mbox_test_device {
 	struct device		*dev;
-	void __iomem		*mmio;
+	void			*mmio;
 	struct mbox_chan	*tx_channel;
 	struct mbox_chan	*rx_channel;
 	char			*rx_buffer;
@@ -53,7 +53,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
 
 	if (count > MBOX_MAX_SIG_LEN) {
 		dev_err(tdev->dev,
-			"Signal length %d greater than max allowed %d\n",
+			"Signal length %zd greater than max allowed %d\n",
 			count, MBOX_MAX_SIG_LEN);
 		return -EINVAL;
 	}
@@ -92,7 +92,7 @@ static ssize_t mbox_test_message_write(struct file *filp,
 
 	if (count > MBOX_MAX_MSG_LEN) {
 		dev_err(tdev->dev,
-			"Message length %d greater than max allowed %d\n",
+			"Message length %zd greater than max allowed %d\n",
 			count, MBOX_MAX_MSG_LEN);
 		return -EINVAL;
 	}
@@ -303,7 +303,7 @@ static int mbox_test_probe(struct platform_device *pdev)
 	tdev->tx_channel = mbox_test_request_channel(pdev, "tx");
 	tdev->rx_channel = mbox_test_request_channel(pdev, "rx");
 
-	if (!tdev->tx_channel && !tdev->tx_channel)
+	if (!tdev->tx_channel && !tdev->rx_channel)
 		return -EPROBE_DEFER;
 
 	tdev->dev = &pdev->dev;
author
#8 lore raw

PATCH v4 5/5 ARM: STi: DT: STiH407: Enable Mailbox testing facility

In reply to Lee Jones

This patch supplies a Client node to enable the Mailbox testing facility. It will be used to send and receive messages from any given co-processor in order to test the STi Mailbox Controller driver.

---
 arch/arm/boot/dts/stih407-family.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/stih407-family.dtsi +6 -0
index 0e5d3ea..e6c8243 100644
@@ -611,6 +611,12 @@
 			st,pwm-num-chan = <4>;
 		};
 
+		mailbox_test {
+			compatible = "mailbox_test";
+			mboxes = <&mailbox2 1 31>, <&mailbox0 1 31>;
+			mbox-names = "tx", "rx";
+		};
+
 		mailbox0: mailbox at 0  {
 			compatible	= "st,stih407-mailbox";
 			reg		= <0x8f00000 0x1000>;
Signature · 1 line
1.9.1
#9 lore raw
In reply to Lee Jones
Quoted 42 lines · Lee Jones

Hi Jassi,

[Resending the updated patch-set this time]

This should be it. Exciting times!

ST's platforms currently support a maximum of 5 Mailboxes, one for each of the supported co-processors situated on the platform. Each Mailbox is divided up into 4 instances which consist of 32 channels. Messages are passed between the application and co-processors using shared memory areas.

Also included in the set is an example Client which should be generic enough to use as a testing environment for all Mailbox IPs which use shared memory or the API to pass messages. With small changes, it should also be able to test more extravagant implementations.

v3 -> v4:
- More protection in MBOX_BASE() MACRO
- Remove unused tx-only marker

v2 => v3:
- Controller
- Shared (DT <=> Device Driver) defines removed
- Return actual error codes instead of NULL in xlate()
- Not passing 'direction' configuration via DT anymore
- Removed all accompanying configuration checking code
- Test F/W
- Allow Rx-only and Tx-only controllers to be tested
- Cater for controllers requiring pre-Tx 'signal' to be sent
- Supply 'wr-' message debugfs file
- When written to, will Tx message through Mailbox Framework
- When read from, will print out a hexdump of Rx'ed message

v1 => v2:
- New MACRO() to obtain base address for a given instance
- Move locking into the structure it protects
- Stop checking for 'ready' state when sending data
- Don't clear channel data (that belongs to the API)
- #define register offsets instead of providing via pdata
- Register driver with module_platform_driver()

Quoted 7 lines

Lee Jones (5):
mailbox: dt: Supply bindings for ST's Mailbox IP
mailbox: Add support for ST's Mailbox IP
ARM: STi: stih407-family: Add nodes for Mailbox
mailbox: Add generic mechanism for testing Mailbox Controllers
ARM: STi: DT: STiH407: Enable Mailbox testing facility

Picked patches 1,2 & 4. Thanks for overhauling the old drivers, now we have fewer lines and simpler but more complete driver.

Thanks.