mailbox: Introduce Texas Instrument's message manager driver
Subsystems (2)
v2 cover mailbox: Introduce Texas Instrument's message manager driver
Hi,
The following v2 of the series provides a base driver for the support of TI's message manager hardware block which facilitates communication between multiple compute engines(or processors) with a central system controller (called PMMC in K2G SoC). Keystone family of TI processors incorporate this solution starting with K2G[1].
The hardware specification is available here:
http://www.ti.com/lit/ug/spruhy8/spruhy8.pdf Chapter 8.1 (Message Manager - NOTE: complete chapter update is estimated to be around March '16).
Starting with K2G SoC, TI Keystone architecture is moving towards an architecture similar to ARM Juno platform with a centralized system controller where all system control takes place - all power management and system control functions are now centralized in this system controller. A protocol called TI-SCI (TI System Control Interface) is built on top of this mailbox driver providing for communication protocol (similar to SCPI drivers/firmware/arm_scpi.c) Follow on patches (once the message manager is accepted) will enable the same. However, an 4.1 kernel based vendor kernel implementation is available at [2].
The following series is functional in TI vendor kernel, however, was tested on K2G EVM using the following test fragment:
http://pastebin.ubuntu.com/15209502/
Boot log: http://pastebin.ubuntu.com/15209436/
baseline: v4.5-rc1
Changes since v1:
- dt binding has been majorly upgraded
- driver updates for the bindings
v1: http://marc.info/?l=devicetree&m=145469015018996&w=2
Nishanth Menon (2):
Documentation: dt: mailbox: Add TI Message Manager
mailbox: Introduce TI message manager driver
.../bindings/mailbox/ti,message-manager.txt | 50 ++ drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/ti-msgmgr.c | 657 +++++++++++++++++++++ include/linux/ti-msgmgr.h | 35 ++ 5 files changed, 755 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/ti,message-manager.txt create mode 100644 drivers/mailbox/ti-msgmgr.c create mode 100644 include/linux/ti-msgmgr.h
[1] K2G support
https://patchwork.kernel.org/patch/8196481/
https://patchwork.kernel.org/patch/8196491/
https://patchwork.kernel.org/patch/8196471/
[2] TISCI support(for reference): (mailbox client driver)
http://git.ti.com/ti-linux-kernel/ti-linux-kernel/blobs/ti-lsk-linux-4.1.y/Documentation/devicetree/bindings/arm/keystone/ti,sci.txt
http://git.ti.com/ti-linux-kernel/ti-linux-kernel/blobs/ti-lsk-linux-4.1.y/drivers/firmware/ti_sci.c
http://git.ti.com/ti-linux-kernel/ti-linux-kernel/blobs/ti-lsk-linux-4.1.y/drivers/firmware/ti_sci.h
http://git.ti.com/ti-linux-kernel/ti-linux-kernel/blobs/ti-lsk-linux-4.1.y/include/linux/ti_sci_protocol.h
The above protocol is used for clock, generic powerdomain, reset etc..
Signature · 1 line
2.7.0
PATCH v2 1/2 Documentation: dt: mailbox: Add TI Message Manager
Message Manager is a hardware block used to communicate with various processor systems within certain Texas Instrument's Keystone generation SoCs.
This hardware engine is used to transfer messages from various compute entities(or processors) within the SoC. It is designed to be self contained without needing software initialization for operation.
---
Changes in V2: major refactor of binding - Thanks for all the review from Rob and Jassi
- Generic compatible property is dropped
- no more child nodes, instead interrupt information is provided as part of the the message manager node it self - part of data moved into driver based on compatible property.
- mbox-cells is 2 (passes queue_id and proxy_id) -added elaboration as well
- change in interrupt names
V1: https://patchwork.kernel.org/patch/8237111/
.../bindings/mailbox/ti,message-manager.txt | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/ti,message-manager.txt
Documentation/devicetree/bindings/mailbox/ti,message-manager.txt new file +50 -0
@@ -0,0 +1,50 @@ +Texas Instruments' Message Manager Driver +======================================== + +The Texas Instruments' Message Manager is a mailbox controller that has +configurable queues selectable at SoC(System on Chip) integration. The Message +manager is broken up into queues in different address regions that are called +"proxies" - each instance is unidirectional and is instantiated at SoC +integration level to indicate receive or transmit path. + +Message Manager Device Node: +=========================== +Required properties: +-------------------- +- compatible: Shall be: "ti,k2g-message-manager" +- reg-names queue_proxy_region - Map the queue proxy region. + queue_state_debug_region - Map the queue state debug + region. +- reg: Contains the register map per reg-names. +- #mbox-cells Shall be 2. Contains the queue ID and proxy ID in that + order referring to the transfer path. +- interrupt-names: Contains interrupt names matching the rx transfer path + for a given SoC. Receive interrupts shall be of the + format: "rx_<QID>_<PID>". + For ti,k2g-message-manager, this shall contain: + "rx_005_002", "rx_057_002" +- interrupts: Contains the interrupt information corresponding to + interrupt-names property. + +Example(K2G): +------------ + + msgmgr: msgmgr at 02a00000 { + compatible = "ti,k2g-message-manager"; + #mbox-cells = <2>; + reg-names = "queue_proxy_region", "queue_state_debug_region"; + reg = <0x02a00000 0x400000>, <0x028c3400 0x400>; + interrupt-names = "rx_005", "rx_057"; + interrupts = <GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH>; + }; + + pmmc: pmmc { + [...] + mbox-names = "rx", "tx"; + # RX queue ID is 5, proxy ID is 2 + # TX queue ID is 0, proxy ID is 0 + mboxes= <&msgmgr 5 2>, + <&msgmgr 0 0>; + [...] + };
Signature · 1 line
2.7.0
Re: [PATCH V2 1/2] Documentation: dt: mailbox: Add TI Message Manager
Quoted 18 lines · Nishanth Menon
Message Manager is a hardware block used to communicate with various processor systems within certain Texas Instrument's Keystone generation SoCs.
This hardware engine is used to transfer messages from various compute entities(or processors) within the SoC. It is designed to be self contained without needing software initialization for operation.
Signed-off-by Nishanth Menon <[email protected]>---
Changes in V2: major refactor of binding - Thanks for all the review from Rob and Jassi
- Generic compatible property is dropped
- no more child nodes, instead interrupt information is provided as part of the the message manager node it self - part of data moved into driver based on compatible property.
- mbox-cells is 2 (passesqueue_idandproxy_id) -added elaboration as well
- change in interrupt names
Quoted 5 lines
V1: https://patchwork.kernel.org/patch/8237111/
.../bindings/mailbox/ti,message-manager.txt | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/ti,message-manager.txt
PATCH v2 2/2 mailbox: Introduce TI message manager driver
In reply to Nishanth MenonSupport for TI Message Manager Module. This hardware block manages a bunch of hardware queues meant for communication between processor entities.
Clients sitting on top of this would manage the required protocol for communicating with the counterpart entities.
For more details on TI Message Manager hardware block, see documentation that will is available here: http://www.ti.com/lit/ug/spruhy8/spruhy8.pdf
Chapter 8.1(Message Manager)
---
V2: Changes since V1:
- Major refactoring of code for binding changes
- moved list of valid K2G queueus into driver
- split up probe into sub functions for easier maintenance
V1: https://patchwork.kernel.org/patch/8237171/
drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/ti-msgmgr.c | 657 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/ti-msgmgr.h | 35 +++ 4 files changed, 705 insertions(+) create mode 100644 drivers/mailbox/ti-msgmgr.c create mode 100644 include/linux/ti-msgmgr.h
drivers/mailbox/Kconfig +11 -0
@@ -78,6 +78,17 @@ config STI_MBOX Mailbox implementation for STMicroelectonics family chips with hardware for interprocessor communication. +config TI_MESSAGE_MANAGER + tristate "Texas Instruments Message Manager Driver" + depends on ARCH_KEYSTONE + help + An implementation of Message Manager slave driver for Keystone + architecture SoCs from Texas Instruments. Message Manager is a + communication entity found on few of Texas Instrument's keystone + architecture SoCs. These may be used for communication between + multiple processors within the SoC. Select this driver if your + platform has support for the hardware block. + config MAILBOX_TEST tristate "Mailbox Test Client" depends on OF
drivers/mailbox/Makefile +2 -0
@@ -17,3 +17,5 @@ obj-$(CONFIG_ALTERA_MBOX) += mailbox-altera.o obj-$(CONFIG_BCM2835_MBOX) += bcm2835-mailbox.o obj-$(CONFIG_STI_MBOX) += mailbox-sti.o + +obj-$(CONFIG_TI_MESSAGE_MANAGER) += ti-msgmgr.o
drivers/mailbox/ti-msgmgr.c new file +657 -0
657 lines not on this page · raw message
include/linux/ti-msgmgr.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Texas Instruments' Message Manager +* +* Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ +* Nishanth Menon +* +* 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. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef TI_MSGMGR_H +#define TI_MSGMGR_H + +/** +* struct ti_msgmgr_message - Message Manager structure +* @len: Length of data in the Buffer +* @buf: Buffer pointer +* +* This is the structure for data used in mbox_send_message +* the length of data buffer used depends on the SoC integration +* parameters - each message may be 64, 128 bytes long depending +* on SoC. Client is supposed to be aware of this. +*/ +struct ti_msgmgr_message { +size_t len; +u8 *buf; +}; + +#endif /* TI_MSGMGR_H */
Signature · 1 line
2.7.0
Jassi Brar
maintainerRe: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 18 lines · Nishanth Menon
Support for TI Message Manager Module. This hardware block manages a bunch of hardware queues meant for communication between processor entities.
Clients sitting on top of this would manage the required protocol for communicating with the counterpart entities.
For more details on TI Message Manager hardware block, see documentation that will is available here: http://www.ti.com/lit/ug/spruhy8/spruhy8.pdf
Chapter 8.1(Message Manager)Signed-off-by Nishanth Menon <[email protected]>---
V2: Changes since V1:
- Major refactoring of code for binding changes
- moved list of valid K2G queueus into driver
- split up probe into sub functions for easier maintenance
Quoted 5 lines
V1: https://patchwork.kernel.org/patch/8237171/
drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/ti-msgmgr.c | 657
Do you want to call it something more specific than 'msgmgr from TI'? Maybe its about Keystone, like mailbox-keystone.c ?
drivers/mailbox/ti-msgmgr.c line 29
Quoted 7 lines
drivers/mailbox/ti-msgmgr.c new file +6
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> +#include <linux/ti-msgmgr.h>
This seems a bit bold. I think include/linux/soc/ti/ is the right place.
Quoted 4 lines
drivers/mailbox/ti-msgmgr.c new file +4
-0+/* Do I actually have messages to read? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (!msg_count) { +/* Shared IRQ? */
drivers/mailbox/ti-msgmgr.c line 195
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+dev_dbg (dev,"Spurious event - 0 pending data!\n" ); +return IRQ_NONE ; + } + +/* +* I have no idea about the protocol being used to communicate with the +* remote producer - 0 could be valid data, so I wont make a judgement +* of how many bytes I should be reading. Let the client figure this +* out.. I just read the full message and pass it on.. +*/
Exactly. And similarly when you send data, you should not have more than one message in transit. Now please see my note in ti_msgmgr_send_data()
Quoted 20 lines
drivers/mailbox/ti-msgmgr.c new file +20
-0+static int ti_msgmgr_send_data (struct mbox_chan *chan,void *data) +{ +struct device *dev = chan->mbox->dev; +struct ti_msgmgr_inst *inst =dev_get_drvdata (dev); +const struct ti_msgmgr_desc *desc; +struct ti_queue_inst *qinst = chan->con_priv; +int msg_count, num_words, trail_bytes; +struct ti_msgmgr_message *message = data; +void __iomem *data_reg; +u32 *word_data; + +if (WARN_ON (!inst)) { +dev_err (dev,"no platform drv data??\n" ); +return -EINVAL ; + } + desc = inst->desc; + +if (desc->max_message_size < message->len) { +dev_err (dev,"Queue %s message length %d > max %d\n" , + qinst->name, message->len, desc->max_message_size);
drivers/mailbox/ti-msgmgr.c line 305
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+return -EINVAL ; + } + +/* Are we able to send this or not? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (msg_count >= desc->max_messages) { +dev_warn (dev,"Queue %s is full (%d messages)\n" , qinst->name, + msg_count); +return -EBUSY ; + }
This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by last_tx_done() before calling send_data() again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.
drivers/mailbox/ti-msgmgr.c line 317
Quoted 11 lines
drivers/mailbox/ti-msgmgr.c new file +11
-0+/* +* NOTE about register access involved here: +* the hardware block is implemented with 32bit access operations and no +* support for data splitting. We don't want the hardware to misbehave +* with sub 32bit access - For example: if the last register write is +* split into byte wise access, it can result in the queue getting +* stuck or dummy messages being transmitted or indeterminate behavior. +* The same can occur if out of order operations take place. +* Hence, we do not use memcpy_toio or ___iowrite32_copy here, instead +* we use writel which ensures the sequencing we need. +*/
.... deja-vu ?
Quoted 18 lines
drivers/mailbox/ti-msgmgr.c new file +18
-0+ +/* Keystone K2G SoC integration details */ +static const struct ti_msgmgr_valid_queue_desc k2g_valid_queues[] = { + {.queue_id =0 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =1 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =2 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =3 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =5 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =56 , .proxy_id =1 , .is_tx = true,}, + {.queue_id =57 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =58 , .proxy_id =3 , .is_tx = true,}, + {.queue_id =59 , .proxy_id =4 , .is_tx = true,}, + {.queue_id =60 , .proxy_id =5 , .is_tx = true,}, + {.queue_id =61 , .proxy_id =6 , .is_tx = true,}, +}; + +static const struct ti_msgmgr_desc k2g_desc = { + .queue_count =64 ,
drivers/mailbox/ti-msgmgr.c line 530
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+ .max_message_size = 64, + .max_messages = 128, + .q_slices = 1, + .q_proxies = 1, + .data_first_reg = 16, + .data_last_reg = 31, + .tx_polled = false, + .valid_queues = k2g_valid_queues, + .num_valid_queues = ARRAY_SIZE(k2g_valid_queues), +};
If these parameters are very configurable, maybe they should be in DT?
Thanks.
Re: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Hi Jassi,
Thanks for reviewing the patch.
On 03/03/2016 11:18 PM, Jassi Brar wrote:
[...]
Quoted 7 lines
Quoted 4 lines
drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/ti-msgmgr.c | 657Do you want to call it something more specific than 'msgmgr from TI'? Maybe its about Keystone, like
mailbox-keystone.c?
Here is the rationale for choosing the name:
There are more than 1 IPC in TI SoCs and even within Keystone SoC. Further, it is indeed called message manager hardware block and used across multiple SoC families (even though it is originated by keystone architecture). we do have a reuse of the omap-mailbox in a future keystone device (in addition to message manager), so using ti-mailbox is more appropriate for omap-mailbox, but anyways.. further renaming this as keystone-mailbox will confuse poor users when the new SoC comes in..
We do have a lot of cross pollination of hardware blocks across TI architectures, and "keystone-" prefix does not really fit the usage. hence the usage of vendor-hardwareblock name.
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c line 29
Quoted 9 lines
drivers/mailbox/ti-msgmgr.c new file +6
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> +#include <linux/ti-msgmgr.h> This seems a bit bold. I think
include/linux/soc/ti/is the right place.
Sure, I can. Since I followed include/linux/omap-mailbox.h, Would you suggest all files such as include/linux/omap* be moved to include/linux/soc/ti/ ? I guess that is not pertinent to this specific patch, but I am curious..
Quoted 46 lines
Quoted 4 lines
drivers/mailbox/ti-msgmgr.c new file +4
-0+/* Do I actually have messages to read? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (!msg_count) { +/* Shared IRQ? */ drivers/mailbox/ti-msgmgr.c line 195
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+dev_dbg (dev,"Spurious event - 0 pending data!\n" ); +return IRQ_NONE ; + } + +/* +* I have no idea about the protocol being used to communicate with the +* remote producer - 0 could be valid data, so I wont make a judgement +* of how many bytes I should be reading. Let the client figure this +* out.. I just read the full message and pass it on.. +*/ Exactly. And similarly when you send data, you should not have more than one message in transit. Now please see my note in
ti_msgmgr_send_data()Quoted 27 lines
drivers/mailbox/ti-msgmgr.c new file +27
-0+static int ti_msgmgr_send_data (struct mbox_chan *chan,void *data) +{ +struct device *dev = chan->mbox->dev; +struct ti_msgmgr_inst *inst =dev_get_drvdata (dev); +const struct ti_msgmgr_desc *desc; +struct ti_queue_inst *qinst = chan->con_priv; +int msg_count, num_words, trail_bytes; +struct ti_msgmgr_message *message = data; +void __iomem *data_reg; +u32 *word_data; + +if (WARN_ON (!inst)) { +dev_err (dev,"no platform drv data??\n" ); +return -EINVAL ; + } + desc = inst->desc; + +if (desc->max_message_size < message->len) { +dev_err (dev,"Queue %s message length %d > max %d\n" , + qinst->name, message->len, desc->max_message_size); +return -EINVAL ; + } + +/* Are we able to send this or not? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,
Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 305
Quoted 3 lines
drivers/mailbox/ti-msgmgr.c new file +3
-0+ msg_count); +return -EBUSY ; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.
OK-> to explain this, few reasons: (queue messages check and usage of last_tx_done are kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b) last_tx_done() is checked if TXDONE_BY_POLL, not if TXDONE_BY_ACK right? which is how this'd work since txdone_poll is false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at the moment(we state txdone_poll at mailbox registration, not at client usage) and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checking last_tx_done forces a single message sequencing - which is not really exploiting the capability of the hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting txdone_poll to false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is - txdone_poll is false.
Quoted 13 lines
drivers/mailbox/ti-msgmgr.c line 317
Quoted 13 lines
drivers/mailbox/ti-msgmgr.c new file +11
-0+/* +* NOTE about register access involved here: +* the hardware block is implemented with 32bit access operations and no +* support for data splitting. We don't want the hardware to misbehave +* with sub 32bit access - For example: if the last register write is +* split into byte wise access, it can result in the queue getting +* stuck or dummy messages being transmitted or indeterminate behavior. +* The same can occur if out of order operations take place. +* Hence, we do not use memcpy_toio or ___iowrite32_copy here, instead +* we use writel which ensures the sequencing we need. +*/
Quoted 1 line
.... deja-vu ?
Tell me about it.. but then, surprises like these do pop in once in a while.. sigh..
Quoted 21 lines
Quoted 21 lines
drivers/mailbox/ti-msgmgr.c new file +21
-0+ +/* Keystone K2G SoC integration details */ +static const struct ti_msgmgr_valid_queue_desc k2g_valid_queues[] = { + {.queue_id =0 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =1 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =2 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =3 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =5 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =56 , .proxy_id =1 , .is_tx = true,}, + {.queue_id =57 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =58 , .proxy_id =3 , .is_tx = true,}, + {.queue_id =59 , .proxy_id =4 , .is_tx = true,}, + {.queue_id =60 , .proxy_id =5 , .is_tx = true,}, + {.queue_id =61 , .proxy_id =6 , .is_tx = true,}, +}; + +static const struct ti_msgmgr_desc k2g_desc = { + .queue_count =64 , + .max_message_size =64 , + .max_messages =128 , + .q_slices =1 ,
Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 530
Quoted 7 lines
drivers/mailbox/ti-msgmgr.c new file +7
-0+ .q_proxies = 1, + .data_first_reg = 16, + .data_last_reg = 31, + .tx_polled = false, + .valid_queues = k2g_valid_queues, + .num_valid_queues = ARRAY_SIZE(k2g_valid_queues), +};If these parameters are very configurable, maybe they should be in DT?
These are SoC integration specific data. based on DT, we will only have SoC specific compatible property in DT. Since the data is tied to SoC integration, there is no benefit of keeping these in DT.
Signature · 2 lines
Regards, Nishanth Menon
Jassi Brar
maintainerRe: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 24 lines · Nishanth Menon
Hi Jassi,
Thanks for reviewing the patch.
On 03/03/2016 11:18 PM, Jassi Brar wrote:[...]
Quoted 7 lines
Quoted 4 lines
drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/ti-msgmgr.c | 657Do you want to call it something more specific than 'msgmgr from TI'? Maybe its about Keystone, like
mailbox-keystone.c?Here is the rationale for choosing the name:
There are more than 1 IPC in TI SoCs and even within Keystone SoC. Further, it is indeed called message manager hardware block and used across multiple SoC families (even though it is originated by keystone architecture). we do have a reuse of the omap-mailbox in a future keystone device (in addition to message manager), so using ti-mailbox is more appropriate for omap-mailbox, but anyways.. further renaming this as keystone-mailbox will confuse poor users when the new SoC comes in..
Quoted 4 lines
We do have a lot of cross pollination of hardware blocks across TI architectures, and "keystone-" prefix does not really fit the usage. hence the usage of vendor-hardwareblock name.
OK, I leave that to you to call it whatever you think is right.
Quoted 10 lines
Quoted 9 lines
drivers/mailbox/ti-msgmgr.c line 29
Quoted 8 lines
drivers/mailbox/ti-msgmgr.c new file +6
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> +#include <linux/ti-msgmgr.h> This seems a bit bold. I think
include/linux/soc/ti/is the right place.
Quoted 5 lines
Sure, I can. Since I followed c, Would you
suggest all files such asinclude/linux/omap*be moved toinclude/linux/soc/ti/? I guess that is not pertinent to this specific patch, but I am curious..
include/linux/omap-mailbox.h predates mailbox api.
But yes, I do think include/linux is not the right place for platform specific headers. include/linux/soc/ is.
Quoted 85 lines
Quoted 47 lines
Quoted 5 lines
drivers/mailbox/ti-msgmgr.c new file +4
-0+/* Do I actually have messages to read? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (!msg_count) { +/* Shared IRQ? */ drivers/mailbox/ti-msgmgr.c line 195
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+dev_dbg (dev,"Spurious event - 0 pending data!\n" ); +return IRQ_NONE ; + } + +/* +* I have no idea about the protocol being used to communicate with the +* remote producer - 0 could be valid data, so I wont make a judgement +* of how many bytes I should be reading. Let the client figure this +* out.. I just read the full message and pass it on.. +*/ Exactly. And similarly when you send data, you should not have more than one message in transit. Now please see my note in
ti_msgmgr_send_data()Quoted 27 lines
drivers/mailbox/ti-msgmgr.c new file +27
-0+static int ti_msgmgr_send_data (struct mbox_chan *chan,void *data) +{ +struct device *dev = chan->mbox->dev; +struct ti_msgmgr_inst *inst =dev_get_drvdata (dev); +const struct ti_msgmgr_desc *desc; +struct ti_queue_inst *qinst = chan->con_priv; +int msg_count, num_words, trail_bytes; +struct ti_msgmgr_message *message = data; +void __iomem *data_reg; +u32 *word_data; + +if (WARN_ON (!inst)) { +dev_err (dev,"no platform drv data??\n" ); +return -EINVAL ; + } + desc = inst->desc; + +if (desc->max_message_size < message->len) { +dev_err (dev,"Queue %s message length %d > max %d\n" , + qinst->name, message->len, desc->max_message_size); +return -EINVAL ; + } + +/* Are we able to send this or not? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 305
Quoted 3 lines
drivers/mailbox/ti-msgmgr.c new file +3
-0+ msg_count); +return -EBUSY ; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of the
Quoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mailbox/ti-msgmgr.c new file +11
-0+/* +* NOTE about register access involved here: +* the hardware block is implemented with 32bit access operations and no +* support for data splitting. We don't want the hardware to misbehave +* with sub 32bit access - For example: if the last register write is +* split into byte wise access, it can result in the queue getting +* stuck or dummy messages being transmitted or indeterminate behavior. +* The same can occur if out of order operations take place. +* Hence, we do not use memcpy_toio or ___iowrite32_copy here, instead +* we use writel which ensures the sequencing we need. +*/
Quoted 5 lines
Quoted 1 line
.... deja-vu ?
Tell me about it.. but then, surprises like these do pop in once in a while.. sigh..
I meant you have same para for read() , so maybe omit this one.
Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
drivers/mailbox/ti-msgmgr.c new file +21
-0+ +/* Keystone K2G SoC integration details */ +static const struct ti_msgmgr_valid_queue_desc k2g_valid_queues[] = { + {.queue_id =0 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =1 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =2 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =3 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =5 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =56 , .proxy_id =1 , .is_tx = true,}, + {.queue_id =57 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =58 , .proxy_id =3 , .is_tx = true,}, + {.queue_id =59 , .proxy_id =4 , .is_tx = true,}, + {.queue_id =60 , .proxy_id =5 , .is_tx = true,}, + {.queue_id =61 , .proxy_id =6 , .is_tx = true,}, +}; + +static const struct ti_msgmgr_desc k2g_desc = { + .queue_count =64 , + .max_message_size =64 , + .max_messages =128 , + .q_slices =1 ,Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 530
Quoted 7 lines
drivers/mailbox/ti-msgmgr.c new file +7
-0+ .q_proxies = 1, + .data_first_reg = 16, + .data_last_reg = 31, + .tx_polled = false, + .valid_queues = k2g_valid_queues, + .num_valid_queues = ARRAY_SIZE(k2g_valid_queues), +};If these parameters are very configurable, maybe they should be in DT?
Quoted 4 lines
These are SoC integration specific data. based on DT, we will only have SoC specific compatible property in DT. Since the data is tied to SoC integration, there is no benefit of keeping these in DT.
Well, yes if the numbers don't change with very often.
Thanks.
Re: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 25 lines · Jassi Brar
Quoted 24 lines · Nishanth Menon
Hi Jassi,
Thanks for reviewing the patch.
On 03/03/2016 11:18 PM, Jassi Brar wrote:[...]
Quoted 7 lines
Quoted 4 lines
drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/ti-msgmgr.c | 657Do you want to call it something more specific than 'msgmgr from TI'? Maybe its about Keystone, like
mailbox-keystone.c?Here is the rationale for choosing the name:
There are more than 1 IPC in TI SoCs and even within Keystone SoC. Further, it is indeed called message manager hardware block and used across multiple SoC families (even though it is originated by keystone architecture). we do have a reuse of the omap-mailbox in a future keystone device (in addition to message manager), so using ti-mailbox is more appropriate for omap-mailbox, but anyways.. further renaming this as keystone-mailbox will confuse poor users when the new SoC comes in..
Quoted 5 lines
Quoted 4 lines
We do have a lot of cross pollination of hardware blocks across TI architectures, and "keystone-" prefix does not really fit the usage. hence the usage of vendor-hardwareblock name.
OK, I leave that to you to call it whatever you think is right.
thanks.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c line 29
Quoted 9 lines
drivers/mailbox/ti-msgmgr.c new file +6
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> +#include <linux/ti-msgmgr.h> This seems a bit bold. I think
include/linux/soc/ti/is the right place.
Quoted 8 lines
Quoted 5 lines
Sure, I can. Since I followed c, Would you
suggest all files such asinclude/linux/omap*be moved toinclude/linux/soc/ti/? I guess that is not pertinent to this specific patch, but I am curious..
include/linux/omap-mailbox.hpredates mailbox api.
But yes, I do thinkinclude/linuxis not the right place for platform specific headers.include/linux/soc/is.
Will fix this.
Quoted 94 lines
Quoted 85 lines
Quoted 47 lines
Quoted 5 lines
drivers/mailbox/ti-msgmgr.c new file +4
-0+/* Do I actually have messages to read? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (!msg_count) { +/* Shared IRQ? */ drivers/mailbox/ti-msgmgr.c line 195
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+dev_dbg (dev,"Spurious event - 0 pending data!\n" ); +return IRQ_NONE ; + } + +/* +* I have no idea about the protocol being used to communicate with the +* remote producer - 0 could be valid data, so I wont make a judgement +* of how many bytes I should be reading. Let the client figure this +* out.. I just read the full message and pass it on.. +*/ Exactly. And similarly when you send data, you should not have more than one message in transit. Now please see my note in
ti_msgmgr_send_data()Quoted 27 lines
drivers/mailbox/ti-msgmgr.c new file +27
-0+static int ti_msgmgr_send_data (struct mbox_chan *chan,void *data) +{ +struct device *dev = chan->mbox->dev; +struct ti_msgmgr_inst *inst =dev_get_drvdata (dev); +const struct ti_msgmgr_desc *desc; +struct ti_queue_inst *qinst = chan->con_priv; +int msg_count, num_words, trail_bytes; +struct ti_msgmgr_message *message = data; +void __iomem *data_reg; +u32 *word_data; + +if (WARN_ON (!inst)) { +dev_err (dev,"no platform drv data??\n" ); +return -EINVAL ; + } + desc = inst->desc; + +if (desc->max_message_size < message->len) { +dev_err (dev,"Queue %s message length %d > max %d\n" , + qinst->name, message->len, desc->max_message_size); +return -EINVAL ; + } + +/* Are we able to send this or not? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 305
Quoted 3 lines
drivers/mailbox/ti-msgmgr.c new file +3
-0+ msg_count); +return -EBUSY ; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of theQuoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.
Quoted 7 lines
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).
Are you suggesting to set txdone_poll is true? the controller is quite capable of queueing more than 1 message at a time. This the reason for letting the client choose the mode of operation - use ack mechanism for operation. client can choose to ignore the buffering in the controller, as you mentioned, but then, why force txdone_poll to true and deny the usage of the queue capability of the hardware?
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/mailbox/ti-msgmgr.c new file +11
-0+/* +* NOTE about register access involved here: +* the hardware block is implemented with 32bit access operations and no +* support for data splitting. We don't want the hardware to misbehave +* with sub 32bit access - For example: if the last register write is +* split into byte wise access, it can result in the queue getting +* stuck or dummy messages being transmitted or indeterminate behavior. +* The same can occur if out of order operations take place. +* Hence, we do not use memcpy_toio or ___iowrite32_copy here, instead +* we use writel which ensures the sequencing we need. +*/
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
.... deja-vu ?
Tell me about it.. but then, surprises like these do pop in once in a while.. sigh..
I meant you have same para for
read(), so maybe omit this one.
Aaah.. OK. i will add something trivial as "similar constraints as read"..
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines
Quoted 18 lines
drivers/mailbox/ti-msgmgr.c new file +18
-0+ +/* Keystone K2G SoC integration details */ +static const struct ti_msgmgr_valid_queue_desc k2g_valid_queues[] = { + {.queue_id =0 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =1 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =2 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =3 , .proxy_id =0 , .is_tx = true,}, + {.queue_id =5 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =56 , .proxy_id =1 , .is_tx = true,}, + {.queue_id =57 , .proxy_id =2 , .is_tx = false,}, + {.queue_id =58 , .proxy_id =3 , .is_tx = true,}, + {.queue_id =59 , .proxy_id =4 , .is_tx = true,}, + {.queue_id =60 , .proxy_id =5 , .is_tx = true,}, + {.queue_id =61 , .proxy_id =6 , .is_tx = true,}, +}; + +static const struct ti_msgmgr_desc k2g_desc = { + .queue_count =64 ,drivers/mailbox/ti-msgmgr.c line 530
Quoted 10 lines
drivers/mailbox/ti-msgmgr.c new file +10
-0+ .max_message_size = 64, + .max_messages = 128, + .q_slices = 1, + .q_proxies = 1, + .data_first_reg = 16, + .data_last_reg = 31, + .tx_polled = false, + .valid_queues = k2g_valid_queues, + .num_valid_queues = ARRAY_SIZE(k2g_valid_queues), +};If these parameters are very configurable, maybe they should be in DT?
Quoted 5 lines
Quoted 4 lines
These are SoC integration specific data. based on DT, we will only have SoC specific compatible property in DT. Since the data is tied to SoC integration, there is no benefit of keeping these in DT.
Well, yes if the numbers don't change with very often.
Hopefully not.
Signature · 2 lines
Regards, Nishanth Menon
Jassi Brar
maintainerRe: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 85 lines · Nishanth Menon
Quoted 76 lines · Jassi Brar
Quoted 66 lines · Nishanth Menon
Quoted 28 lines
Quoted 28 lines
drivers/mailbox/ti-msgmgr.c new file +27
-0+static int ti_msgmgr_send_data (struct mbox_chan *chan,void *data) +{ +struct device *dev = chan->mbox->dev; +struct ti_msgmgr_inst *inst =dev_get_drvdata (dev); +const struct ti_msgmgr_desc *desc; +struct ti_queue_inst *qinst = chan->con_priv; +int msg_count, num_words, trail_bytes; +struct ti_msgmgr_message *message = data; +void __iomem *data_reg; +u32 *word_data; + +if (WARN_ON (!inst)) { +dev_err (dev,"no platform drv data??\n" ); +return -EINVAL ; + } + desc = inst->desc; + +if (desc->max_message_size < message->len) { +dev_err (dev,"Queue %s message length %d > max %d\n" , + qinst->name, message->len, desc->max_message_size); +return -EINVAL ; + } + +/* Are we able to send this or not? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 305
Quoted 3 lines
drivers/mailbox/ti-msgmgr.c new file +3
-0+ msg_count); +return -EBUSY ; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of theQuoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.Quoted 7 lines
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).
Quoted 1 line
Are you suggesting to set
txdone_pollis true?
No.
Quoted 7 lines
the controller is quite
capable of queueing more than 1 message at a time. This the reason for letting the client choose the mode of operation - use ack mechanism for operation. client can choose to ignore the buffering in the controller, as you mentioned, but then, why forcetxdone_pollto true and deny the usage of the queue capability of the hardware?
irq/poll/ack whatever you use, there is no valid reason to buffer messages in the controller driver. Please let me know what usecase you have in mind that must have messages buffered in controller driver and not core.
Thanks.
Re: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Jassi,
Quoted 96 lines · Jassi Brar
Quoted 85 lines · Nishanth Menon
Quoted 76 lines · Jassi Brar
Quoted 66 lines · Nishanth Menon
Quoted 28 lines
Quoted 28 lines
drivers/mailbox/ti-msgmgr.c new file +27
-0+static int ti_msgmgr_send_data (struct mbox_chan *chan,void *data) +{ +struct device *dev = chan->mbox->dev; +struct ti_msgmgr_inst *inst =dev_get_drvdata (dev); +const struct ti_msgmgr_desc *desc; +struct ti_queue_inst *qinst = chan->con_priv; +int msg_count, num_words, trail_bytes; +struct ti_msgmgr_message *message = data; +void __iomem *data_reg; +u32 *word_data; + +if (WARN_ON (!inst)) { +dev_err (dev,"no platform drv data??\n" ); +return -EINVAL ; + } + desc = inst->desc; + +if (desc->max_message_size < message->len) { +dev_err (dev,"Queue %s message length %d > max %d\n" , + qinst->name, message->len, desc->max_message_size); +return -EINVAL ; + } + +/* Are we able to send this or not? */ + msg_count =ti_msgmgr_queue_get_num_messages (qinst); +if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
drivers/mailbox/ti-msgmgr.c line 305
Quoted 3 lines
drivers/mailbox/ti-msgmgr.c new file +3
-0+ msg_count); +return -EBUSY ; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of theQuoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.Quoted 7 lines
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).Quoted 1 line
Are you suggesting to set
txdone_pollis true?No.
Quoted 7 lines
the controller is quite
capable of queueing more than 1 message at a time. This the reason for letting the client choose the mode of operation - use ack mechanism for operation. client can choose to ignore the buffering in the controller, as you mentioned, but then, why forcetxdone_pollto true and deny the usage of the queue capability of the hardware?
Quoted 4 lines
irq/poll/ack whatever you use, there is no valid reason to buffer messages in the controller driver. Please let me know what usecase you have in mind that must have messages buffered in controller driver and not core.
I am confused, I am _not_ buffering any tx data in the controller driver - rx data is stored in a temp buffer to send up the stack - that is just regular practise, right?. In tx, I just check to ensure that the queue has'nt run out prior to transmission since the hardware is capable of queueing - ok, in a single transmitter system it is probably a little overkill, but we would like to function in multiple producer SoC as well. What am I missing here?
Signature · 3 lines
--- Regards, Nishanth Menon
Jassi Brar
maintainerRe: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 99 lines · Nishanth Menon
Jassi,
Quoted 96 lines · Jassi Brar
Quoted 85 lines · Nishanth Menon
Quoted 76 lines · Jassi Brar
Quoted 66 lines · Nishanth Menon
Quoted 28 lines
Quoted 28 lines
(quoted diff) +27
-0+static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) +{ + struct device *dev = chan->mbox->dev; + struct ti_msgmgr_inst *inst = dev_get_drvdata(dev); + const struct ti_msgmgr_desc *desc; + struct ti_queue_inst *qinst = chan->con_priv; + int msg_count, num_words, trail_bytes; + struct ti_msgmgr_message *message = data; + void __iomem *data_reg; + u32 *word_data; + + if (WARN_ON(!inst)) { + dev_err(dev, "no platform drv data??\n"); + return -EINVAL; + } + desc = inst->desc; + + if (desc->max_message_size < message->len) { + dev_err(dev, "Queue %s message length %d > max %d\n", + qinst->name, message->len, desc->max_message_size); + return -EINVAL; + } + + /* Are we able to send this or not? */ + msg_count = ti_msgmgr_queue_get_num_messages(qinst); + if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ msg_count); + return -EBUSY; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of theQuoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.Quoted 7 lines
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).Quoted 1 line
Are you suggesting to set
txdone_pollis true?No.
Quoted 7 lines
the controller is quite
capable of queueing more than 1 message at a time. This the reason for letting the client choose the mode of operation - use ack mechanism for operation. client can choose to ignore the buffering in the controller, as you mentioned, but then, why forcetxdone_pollto true and deny the usage of the queue capability of the hardware?
Quoted 9 lines
Quoted 4 lines
irq/poll/ack whatever you use, there is no valid reason to buffer messages in the controller driver. Please let me know what usecase you have in mind that must have messages buffered in controller driver and not core.
I am confused, I am _not_ buffering any tx data in the controller driver - rx data is stored in a temp buffer to send up the stack - that is just regular practise, right?
right.
Quoted 6 lines
In tx, I just check to ensure
that the queue has'nt run out prior to transmission since the hardware is capable of queueing - ok, in a single transmitter system it is probably a little overkill, but we would like to function in multiple producer SoC as well. What am I missing here?
In send_data() you have ...
+ /* Are we able to send this or not? */
+ msg_count = ti_msgmgr_queue_get_num_messages(qinst);
+ if (msg_count >= desc->max_messages) {+ dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,
+ msg_count);
+ return -EBUSY;
+ }
That is, you check if there are some messages in the TX-Queue already. I am not sure how you could hit this and if that is legit.
Re: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 127 lines · Jassi Brar
Quoted 99 lines · Nishanth Menon
Jassi,
Quoted 96 lines · Jassi Brar
Quoted 85 lines · Nishanth Menon
Quoted 76 lines · Jassi Brar
Quoted 66 lines · Nishanth Menon
Quoted 28 lines
Quoted 28 lines
(quoted diff) +27
-0+static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) +{ + struct device *dev = chan->mbox->dev; + struct ti_msgmgr_inst *inst = dev_get_drvdata(dev); + const struct ti_msgmgr_desc *desc; + struct ti_queue_inst *qinst = chan->con_priv; + int msg_count, num_words, trail_bytes; + struct ti_msgmgr_message *message = data; + void __iomem *data_reg; + u32 *word_data; + + if (WARN_ON(!inst)) { + dev_err(dev, "no platform drv data??\n"); + return -EINVAL; + } + desc = inst->desc; + + if (desc->max_message_size < message->len) { + dev_err(dev, "Queue %s message length %d > max %d\n", + qinst->name, message->len, desc->max_message_size); + return -EINVAL; + } + + /* Are we able to send this or not? */ + msg_count = ti_msgmgr_queue_get_num_messages(qinst); + if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ msg_count); + return -EBUSY; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of theQuoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.Quoted 7 lines
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).Quoted 1 line
Are you suggesting to set
txdone_pollis true?No.
Quoted 7 lines
the controller is quite
capable of queueing more than 1 message at a time. This the reason for letting the client choose the mode of operation - use ack mechanism for operation. client can choose to ignore the buffering in the controller, as you mentioned, but then, why forcetxdone_pollto true and deny the usage of the queue capability of the hardware?Quoted 9 lines
Quoted 4 lines
irq/poll/ack whatever you use, there is no valid reason to buffer messages in the controller driver. Please let me know what usecase you have in mind that must have messages buffered in controller driver and not core.
I am confused, I am _not_ buffering any tx data in the controller driver - rx data is stored in a temp buffer to send up the stack - that is just regular practise, right?
right.
Quoted 6 lines
In tx, I just check to ensure
that the queue has'nt run out prior to transmission since the hardware is capable of queueing - ok, in a single transmitter system it is probably a little overkill, but we would like to function in multiple producer SoC as well. What am I missing here?In
send_data()you have ...(quoted diff) +7
-0+ /* Are we able to send this or not? */ + msg_count = ti_msgmgr_queue_get_num_messages(qinst); + if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name, + msg_count); + return -EBUSY; + }
Quoted 2 lines
That is, you check if there are some messages in the TX-Queue already. I am not sure how you could hit this and if that is legit.
Alright, i will drop this check since it is causing a lot more confusion that that is worth. we can introduce it when we finally do hit an issue eventually with multiple processors trying to transmit on the same queue manager. that is not a concern at the very immediate time, so we should be good to drop.
please let me know if you are ok with this.
Signature · 3 lines
--- Regards, Nishanth Menon
Jassi Brar
maintainerRe: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Quoted 128 lines · Nishanth Menon
Quoted 127 lines · Jassi Brar
Quoted 99 lines · Nishanth Menon
Jassi,
Quoted 96 lines · Jassi Brar
Quoted 85 lines · Nishanth Menon
Quoted 76 lines · Jassi Brar
Quoted 66 lines · Nishanth Menon
Quoted 28 lines
Quoted 28 lines
(quoted diff) +27
-0+static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) +{ + struct device *dev = chan->mbox->dev; + struct ti_msgmgr_inst *inst = dev_get_drvdata(dev); + const struct ti_msgmgr_desc *desc; + struct ti_queue_inst *qinst = chan->con_priv; + int msg_count, num_words, trail_bytes; + struct ti_msgmgr_message *message = data; + void __iomem *data_reg; + u32 *word_data; + + if (WARN_ON(!inst)) { + dev_err(dev, "no platform drv data??\n"); + return -EINVAL; + } + desc = inst->desc; + + if (desc->max_message_size < message->len) { + dev_err(dev, "Queue %s message length %d > max %d\n", + qinst->name, message->len, desc->max_message_size); + return -EINVAL; + } + + /* Are we able to send this or not? */ + msg_count = ti_msgmgr_queue_get_num_messages(qinst); + if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name,Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ msg_count); + return -EBUSY; + }This seems fishy. mailbox api always submit 1 'complete' message to be sent and checks for completion by
last_tx_done()before callingsend_data()again. Controller drivers are not supposed to queue messages - mailbox core does. So you should never be unable to send a message.OK-> to explain this, few reasons: (queue messages check and usage of
last_tx_doneare kind of intertwined answer..
a) we need to remember that the message manager has a shared RAM. multiple transmitter over other queues can be sharing the same. unfortunately, we dont get a threshold kind of interrupt or status that I am able to exploit in the current incarnation of the solution. The best we can do in the full system is to constrain the number of messages that are max pending simultaneously in each of the queue from various transmitters in the SoC.
b)last_tx_done()is checked ifTXDONE_BY_POLL, not ifTXDONE_BY_ACKright? which is how this'd work sincetxdone_pollis false -> that is how we want this mechanism to work once the far end is ready for next message, it acks. I do see your point about being tied to protocol - I dont like it either.. in fact, I'd prefer that client registration mention what kind of handshaking is necessary, but: a) that is not how mailbox framework is constructed at themoment(we state txdone_poll at mailbox registration, not at client usage)and b) I have no real need for multiple clients to users of message manager who actually need non-ACK usage - even for the foreseeable future (at least 1 next generation of SoC) - if such a need does arise in the future, I will have to rework framework and make this capability at the registration time of the client - allowing each client path to use different mechanisms on hardware such as these that need it.
c) message manager can actually queue more than one message(depending on client capability). Even though, at this point, we are not really capable of doing it(again from what I can see for immediate future), mailbox framework by checkinglast_tx_doneforces a single message sequencing - which is not really exploiting the capability of theQuoted 9 lines
hardware - in theory, we should be able to queue max num messages, hit cpuidle and snooze away while the remote entity chomp away data at it's own pace and finally give us a notification back - but again, we can argue it is indeed protocol dependent, so setting
txdone_pollto false actually enables that to be done in user. Again - i have no immediate need for any queued multiple transfer needs yet.. even if i need to, in the future, it can easily be done by the client by maintaining code as is -txdone_pollis false.Quoted 7 lines
All I suggest is that the controller does not queue more than 1 message at a time, which means the controller driver allows for maximum possible resources taken by a message.
The buffering is already done by the core, and if for your 'batch dispatch' thing the client could simply flush them to remote by pretending it got the ack (which is no worse than simply sending all messages to remote without caring if the first was successful or not).Quoted 1 line
Are you suggesting to set
txdone_pollis true?No.
Quoted 7 lines
the controller is quite
capable of queueing more than 1 message at a time. This the reason for letting the client choose the mode of operation - use ack mechanism for operation. client can choose to ignore the buffering in the controller, as you mentioned, but then, why forcetxdone_pollto true and deny the usage of the queue capability of the hardware?Quoted 9 lines
Quoted 4 lines
irq/poll/ack whatever you use, there is no valid reason to buffer messages in the controller driver. Please let me know what usecase you have in mind that must have messages buffered in controller driver and not core.
I am confused, I am _not_ buffering any tx data in the controller driver - rx data is stored in a temp buffer to send up the stack - that is just regular practise, right?
right.
Quoted 6 lines
In tx, I just check to ensure
that the queue has'nt run out prior to transmission since the hardware is capable of queueing - ok, in a single transmitter system it is probably a little overkill, but we would like to function in multiple producer SoC as well. What am I missing here?In
send_data()you have ...(quoted diff) +7
-0+ /* Are we able to send this or not? */ + msg_count = ti_msgmgr_queue_get_num_messages(qinst); + if (msg_count >= desc->max_messages) { + dev_warn(dev, "Queue %s is full (%d messages)\n", qinst->name, + msg_count); + return -EBUSY; + }
Quoted 6 lines
Quoted 2 lines
That is, you check if there are some messages in the TX-Queue already. I am not sure how you could hit this and if that is legit.
Alright, i will drop this check since it is causing a lot more confusion
It's confusing because you check ti_msgmgr_queue_get_num_messages() also in ti_msgmgr_last_tx_done() which doesn't make sense because the former accounts for messages from other senders also (as you say there could be multiple senders).
Quoted 7 lines
that that is worth. we can introduce it when we finally do hit an issue eventually with multiple processors trying to transmit on the same queue manager. that is not a concern at the very immediate time, so we should be good to drop.
please let me know if you are ok with this.
I am ok with whatever you assert is needed for your platform. I just point out what I think are inconsistencies in your assumptions. I'll pick the next revision however it is.
Thanks.
Re: [PATCH V2 2/2] mailbox: Introduce TI message manager driver
Hi Jassi,
On 03/16/2016 12:16 AM, Jassi Brar wrote:
[...]
Quoted 7 lines
Quoted 3 lines
Alright, i will drop this check since it is causing a lot more confusion
It's confusing because you check
ti_msgmgr_queue_get_num_messages()also inti_msgmgr_last_tx_done()which doesn't make sense because the former accounts for messages from other senders also (as you say there could be multiple senders).
True -> I will drop it for now. I will see if the case I was trying to protect is actually possible to be hit in the first place. And if proven to be required, I will introduce it back with a better explanation and the usecase where this is needed.
Quoted 10 lines
Quoted 7 lines
that that is worth. we can introduce it when we finally do hit an issue eventually with multiple processors trying to transmit on the same queue manager. that is not a concern at the very immediate time, so we should be good to drop.
please let me know if you are ok with this.
I am ok with whatever you assert is needed for your platform. I just point out what I think are inconsistencies in your assumptions. I'll pick the next revision however it is.
Thanks for your patience and guidance with this series. I have tried to incorporate all the alignment we have had on this thread as part of V3[1] of the series.
[1] http://marc.info/?l=linux-arm-kernel&m=145817434531691&w=2
Signature · 2 lines
Regards, Nishanth Menon