Message ID | 1351859566-24818-2-git-send-email-vaibhav.bedia@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
* Vaibhav Bedia <vaibhav.bedia@ti.com> [121102 05:35]: > On AM33XX, the mailbox module between the MPU and the > WKUP-M3 co-processor facilitates a one-way communication. > MPU uses the assigned mailbox sub-module to issue the > interrupt to the WKUP-M3 co-processor which then goes > and reads the the IPC data from registers in the control > module. > > WKUP-M3 is in the L4_WKUP and does not have any access to > the Mailbox module. Due to this limitation, the MPU is > completely responsible for FIFO maintenance and interrupt > generation. MPU needs to ensure that the FIFO does not > overflow by reading by the assigned mailbox sub-module. > > This patch adds an API in the mailbox code which the MPU > can use to empty the FIFO by issuing a readback command. > > Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com> > --- > arch/arm/mach-omap2/mailbox.c | 42 ++++++++++++++++++++--------- > arch/arm/plat-omap/include/plat/mailbox.h | 3 ++ > arch/arm/plat-omap/mailbox.c | 35 ++++++++++++++++++++++++ Patches have been posted to move the mailbox related files out of arch/arm, so you'll have to update those for that. Please see thread "[PATCH 0/2] ARM: OMAP: mailbox out of plat code" for more information. Regards, Tony
Hi Tony, On Sat, Nov 03, 2012 at 00:30:04, Tony Lindgren wrote: [...] > > Patches have been posted to move the mailbox related > files out of arch/arm, so you'll have to update those > for that. Please see thread "[PATCH 0/2] ARM: OMAP: > mailbox out of plat code" for more information. > Thanks for pointing this out. I'll update the patches for these. I had used your master branch as the baseline. Some of the patches also need rework to account the header file and timer code changes. Is there some other branch of yours that I could use or should I just mention the dependencies in the next version of patches? Regards, Vaibhav
On Friday 02 November 2012 06:02 PM, Vaibhav Bedia wrote: > On AM33XX, the mailbox module between the MPU and the > WKUP-M3 co-processor facilitates a one-way communication. > MPU uses the assigned mailbox sub-module to issue the > interrupt to the WKUP-M3 co-processor which then goes > and reads the the IPC data from registers in the control > module. > > WKUP-M3 is in the L4_WKUP and does not have any access to > the Mailbox module. Due to this limitation, the MPU is > completely responsible for FIFO maintenance and interrupt > generation. MPU needs to ensure that the FIFO does not > overflow by reading by the assigned mailbox sub-module. > > This patch adds an API in the mailbox code which the MPU > can use to empty the FIFO by issuing a readback command. > > Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com> > --- > arch/arm/mach-omap2/mailbox.c | 42 ++++++++++++++++++++--------- > arch/arm/plat-omap/include/plat/mailbox.h | 3 ++ > arch/arm/plat-omap/mailbox.c | 35 ++++++++++++++++++++++++ > 3 files changed, 67 insertions(+), 13 deletions(-) > > diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c > index 0d97456..f38b4fa 100644 > --- a/arch/arm/mach-omap2/mailbox.c > +++ b/arch/arm/mach-omap2/mailbox.c > @@ -123,6 +123,20 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox) > return mbox_read_reg(fifo->fifo_stat); > } > > +static int omap2_mbox_fifo_needs_flush(struct omap_mbox *mbox) > +{ > + struct omap_mbox2_fifo *fifo = > + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; type casting is generally avoided in linux code. > + return mbox_read_reg(fifo->msg_stat); > +} > + > +static mbox_msg_t omap2_mbox_fifo_readback(struct omap_mbox *mbox) > +{ > + struct omap_mbox2_fifo *fifo = > + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; > + return (mbox_msg_t) mbox_read_reg(fifo->msg); same here. > +} > + > /* Mailbox IRQ handle functions */ > static void omap2_mbox_enable_irq(struct omap_mbox *mbox, > omap_mbox_type_t irq) > @@ -205,19 +219,21 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) > } > > static struct omap_mbox_ops omap2_mbox_ops = { > - .type = OMAP_MBOX_TYPE2, > - .startup = omap2_mbox_startup, > - .shutdown = omap2_mbox_shutdown, > - .fifo_read = omap2_mbox_fifo_read, > - .fifo_write = omap2_mbox_fifo_write, > - .fifo_empty = omap2_mbox_fifo_empty, > - .fifo_full = omap2_mbox_fifo_full, > - .enable_irq = omap2_mbox_enable_irq, > - .disable_irq = omap2_mbox_disable_irq, > - .ack_irq = omap2_mbox_ack_irq, > - .is_irq = omap2_mbox_is_irq, > - .save_ctx = omap2_mbox_save_ctx, > - .restore_ctx = omap2_mbox_restore_ctx, > + .type = OMAP_MBOX_TYPE2, > + .startup = omap2_mbox_startup, > + .shutdown = omap2_mbox_shutdown, > + .fifo_read = omap2_mbox_fifo_read, > + .fifo_write = omap2_mbox_fifo_write, > + .fifo_empty = omap2_mbox_fifo_empty, > + .fifo_full = omap2_mbox_fifo_full, > + .fifo_needs_flush = omap2_mbox_fifo_needs_flush, > + .fifo_readback = omap2_mbox_fifo_readback, > + .enable_irq = omap2_mbox_enable_irq, > + .disable_irq = omap2_mbox_disable_irq, > + .ack_irq = omap2_mbox_ack_irq, > + .is_irq = omap2_mbox_is_irq, > + .save_ctx = omap2_mbox_save_ctx, > + .restore_ctx = omap2_mbox_restore_ctx, You should do the indentation fix in another patch. > }; > > /* > diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h > index cc3921e..e136529 100644 > --- a/arch/arm/plat-omap/include/plat/mailbox.h > +++ b/arch/arm/plat-omap/include/plat/mailbox.h > @@ -29,6 +29,8 @@ struct omap_mbox_ops { > void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg); > int (*fifo_empty)(struct omap_mbox *mbox); > int (*fifo_full)(struct omap_mbox *mbox); > + int (*fifo_needs_flush)(struct omap_mbox *mbox); > + mbox_msg_t (*fifo_readback)(struct omap_mbox *mbox); Do you think passing the msg structure as an argument and letting the function populate it will be better instead of returning the msg structure ? No strong opinion since from read_foo() point of view what you have done might be right thing. In either case, please get rid of typecasting. Regards Santosh
On Sat, Nov 03, 2012 at 21:33:47, Shilimkar, Santosh wrote: [...] > > +static int omap2_mbox_fifo_needs_flush(struct omap_mbox *mbox) > > +{ > > + struct omap_mbox2_fifo *fifo = > > + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; > type casting is generally avoided in linux code. I was just trying to be consistent with the rest of the mailbox FIFO related code :) Will see how to get rid of these globally in the next version. > > + return mbox_read_reg(fifo->msg_stat); > > +} > > + > > +static mbox_msg_t omap2_mbox_fifo_readback(struct omap_mbox *mbox) > > +{ > > + struct omap_mbox2_fifo *fifo = > > + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; > > + return (mbox_msg_t) mbox_read_reg(fifo->msg); > same here. Ok. > > +} > > + > > /* Mailbox IRQ handle functions */ > > static void omap2_mbox_enable_irq(struct omap_mbox *mbox, > > omap_mbox_type_t irq) > > @@ -205,19 +219,21 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) > > } > > > > static struct omap_mbox_ops omap2_mbox_ops = { > > - .type = OMAP_MBOX_TYPE2, > > - .startup = omap2_mbox_startup, > > - .shutdown = omap2_mbox_shutdown, > > - .fifo_read = omap2_mbox_fifo_read, > > - .fifo_write = omap2_mbox_fifo_write, > > - .fifo_empty = omap2_mbox_fifo_empty, > > - .fifo_full = omap2_mbox_fifo_full, > > - .enable_irq = omap2_mbox_enable_irq, > > - .disable_irq = omap2_mbox_disable_irq, > > - .ack_irq = omap2_mbox_ack_irq, > > - .is_irq = omap2_mbox_is_irq, > > - .save_ctx = omap2_mbox_save_ctx, > > - .restore_ctx = omap2_mbox_restore_ctx, > > + .type = OMAP_MBOX_TYPE2, > > + .startup = omap2_mbox_startup, > > + .shutdown = omap2_mbox_shutdown, > > + .fifo_read = omap2_mbox_fifo_read, > > + .fifo_write = omap2_mbox_fifo_write, > > + .fifo_empty = omap2_mbox_fifo_empty, > > + .fifo_full = omap2_mbox_fifo_full, > > + .fifo_needs_flush = omap2_mbox_fifo_needs_flush, > > + .fifo_readback = omap2_mbox_fifo_readback, > > + .enable_irq = omap2_mbox_enable_irq, > > + .disable_irq = omap2_mbox_disable_irq, > > + .ack_irq = omap2_mbox_ack_irq, > > + .is_irq = omap2_mbox_is_irq, > > + .save_ctx = omap2_mbox_save_ctx, > > + .restore_ctx = omap2_mbox_restore_ctx, > You should do the indentation fix in another patch. > Ok will split it up. > > }; > > > > /* > > diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h > > index cc3921e..e136529 100644 > > --- a/arch/arm/plat-omap/include/plat/mailbox.h > > +++ b/arch/arm/plat-omap/include/plat/mailbox.h > > @@ -29,6 +29,8 @@ struct omap_mbox_ops { > > void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg); > > int (*fifo_empty)(struct omap_mbox *mbox); > > int (*fifo_full)(struct omap_mbox *mbox); > > + int (*fifo_needs_flush)(struct omap_mbox *mbox); > > + mbox_msg_t (*fifo_readback)(struct omap_mbox *mbox); > Do you think passing the msg structure as an argument and letting the > function populate it will be better instead of returning the msg > structure ? No strong opinion since from read_foo() point of view > what you have done might be right thing. In either case, please > get rid of typecasting. > Passing the msg structure looks fine. Will do that in the next version. Regards, Vaibhav
On Sunday 04 November 2012 08:56 PM, Bedia, Vaibhav wrote: > On Sat, Nov 03, 2012 at 21:33:47, Shilimkar, Santosh wrote: > [...] > >>> +static int omap2_mbox_fifo_needs_flush(struct omap_mbox *mbox) >>> +{ >>> + struct omap_mbox2_fifo *fifo = >>> + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; >> type casting is generally avoided in linux code. > > I was just trying to be consistent with the rest of the mailbox FIFO > related code :) > > Will see how to get rid of these globally in the next version. > >>> + return mbox_read_reg(fifo->msg_stat); >>> +} >>> + >>> +static mbox_msg_t omap2_mbox_fifo_readback(struct omap_mbox *mbox) >>> +{ >>> + struct omap_mbox2_fifo *fifo = >>> + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; >>> + return (mbox_msg_t) mbox_read_reg(fifo->msg); >> same here. > > Ok. > >>> +} >>> + >>> /* Mailbox IRQ handle functions */ >>> static void omap2_mbox_enable_irq(struct omap_mbox *mbox, >>> omap_mbox_type_t irq) >>> @@ -205,19 +219,21 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) >>> } >>> >>> static struct omap_mbox_ops omap2_mbox_ops = { >>> - .type = OMAP_MBOX_TYPE2, >>> - .startup = omap2_mbox_startup, >>> - .shutdown = omap2_mbox_shutdown, >>> - .fifo_read = omap2_mbox_fifo_read, >>> - .fifo_write = omap2_mbox_fifo_write, >>> - .fifo_empty = omap2_mbox_fifo_empty, >>> - .fifo_full = omap2_mbox_fifo_full, >>> - .enable_irq = omap2_mbox_enable_irq, >>> - .disable_irq = omap2_mbox_disable_irq, >>> - .ack_irq = omap2_mbox_ack_irq, >>> - .is_irq = omap2_mbox_is_irq, >>> - .save_ctx = omap2_mbox_save_ctx, >>> - .restore_ctx = omap2_mbox_restore_ctx, >>> + .type = OMAP_MBOX_TYPE2, >>> + .startup = omap2_mbox_startup, >>> + .shutdown = omap2_mbox_shutdown, >>> + .fifo_read = omap2_mbox_fifo_read, >>> + .fifo_write = omap2_mbox_fifo_write, >>> + .fifo_empty = omap2_mbox_fifo_empty, >>> + .fifo_full = omap2_mbox_fifo_full, >>> + .fifo_needs_flush = omap2_mbox_fifo_needs_flush, >>> + .fifo_readback = omap2_mbox_fifo_readback, >>> + .enable_irq = omap2_mbox_enable_irq, >>> + .disable_irq = omap2_mbox_disable_irq, >>> + .ack_irq = omap2_mbox_ack_irq, >>> + .is_irq = omap2_mbox_is_irq, >>> + .save_ctx = omap2_mbox_save_ctx, >>> + .restore_ctx = omap2_mbox_restore_ctx, >> You should do the indentation fix in another patch. >> > > Ok will split it up. > >>> }; >>> >>> /* >>> diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h >>> index cc3921e..e136529 100644 >>> --- a/arch/arm/plat-omap/include/plat/mailbox.h >>> +++ b/arch/arm/plat-omap/include/plat/mailbox.h >>> @@ -29,6 +29,8 @@ struct omap_mbox_ops { >>> void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg); >>> int (*fifo_empty)(struct omap_mbox *mbox); >>> int (*fifo_full)(struct omap_mbox *mbox); >>> + int (*fifo_needs_flush)(struct omap_mbox *mbox); >>> + mbox_msg_t (*fifo_readback)(struct omap_mbox *mbox); >> Do you think passing the msg structure as an argument and letting the >> function populate it will be better instead of returning the msg >> structure ? No strong opinion since from read_foo() point of view >> what you have done might be right thing. In either case, please >> get rid of typecasting. >> > > Passing the msg structure looks fine. Will do that in the next version. > OK Regards Santosh
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index 0d97456..f38b4fa 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c @@ -123,6 +123,20 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox) return mbox_read_reg(fifo->fifo_stat); } +static int omap2_mbox_fifo_needs_flush(struct omap_mbox *mbox) +{ + struct omap_mbox2_fifo *fifo = + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; + return mbox_read_reg(fifo->msg_stat); +} + +static mbox_msg_t omap2_mbox_fifo_readback(struct omap_mbox *mbox) +{ + struct omap_mbox2_fifo *fifo = + &((struct omap_mbox2_priv *)mbox->priv)->tx_fifo; + return (mbox_msg_t) mbox_read_reg(fifo->msg); +} + /* Mailbox IRQ handle functions */ static void omap2_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_type_t irq) @@ -205,19 +219,21 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) } static struct omap_mbox_ops omap2_mbox_ops = { - .type = OMAP_MBOX_TYPE2, - .startup = omap2_mbox_startup, - .shutdown = omap2_mbox_shutdown, - .fifo_read = omap2_mbox_fifo_read, - .fifo_write = omap2_mbox_fifo_write, - .fifo_empty = omap2_mbox_fifo_empty, - .fifo_full = omap2_mbox_fifo_full, - .enable_irq = omap2_mbox_enable_irq, - .disable_irq = omap2_mbox_disable_irq, - .ack_irq = omap2_mbox_ack_irq, - .is_irq = omap2_mbox_is_irq, - .save_ctx = omap2_mbox_save_ctx, - .restore_ctx = omap2_mbox_restore_ctx, + .type = OMAP_MBOX_TYPE2, + .startup = omap2_mbox_startup, + .shutdown = omap2_mbox_shutdown, + .fifo_read = omap2_mbox_fifo_read, + .fifo_write = omap2_mbox_fifo_write, + .fifo_empty = omap2_mbox_fifo_empty, + .fifo_full = omap2_mbox_fifo_full, + .fifo_needs_flush = omap2_mbox_fifo_needs_flush, + .fifo_readback = omap2_mbox_fifo_readback, + .enable_irq = omap2_mbox_enable_irq, + .disable_irq = omap2_mbox_disable_irq, + .ack_irq = omap2_mbox_ack_irq, + .is_irq = omap2_mbox_is_irq, + .save_ctx = omap2_mbox_save_ctx, + .restore_ctx = omap2_mbox_restore_ctx, }; /* diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h index cc3921e..e136529 100644 --- a/arch/arm/plat-omap/include/plat/mailbox.h +++ b/arch/arm/plat-omap/include/plat/mailbox.h @@ -29,6 +29,8 @@ struct omap_mbox_ops { void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg); int (*fifo_empty)(struct omap_mbox *mbox); int (*fifo_full)(struct omap_mbox *mbox); + int (*fifo_needs_flush)(struct omap_mbox *mbox); + mbox_msg_t (*fifo_readback)(struct omap_mbox *mbox); /* irq */ void (*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq); @@ -61,6 +63,7 @@ struct omap_mbox { struct blocking_notifier_head notifier; }; +int omap_mbox_msg_rx_flush(struct omap_mbox *mbox); int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg); void omap_mbox_init_seq(struct omap_mbox *); diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c index 42377ef..cb9754a 100644 --- a/arch/arm/plat-omap/mailbox.c +++ b/arch/arm/plat-omap/mailbox.c @@ -59,6 +59,14 @@ static inline int mbox_fifo_full(struct omap_mbox *mbox) { return mbox->ops->fifo_full(mbox); } +static inline int mbox_fifo_needs_flush(struct omap_mbox *mbox) +{ + return mbox->ops->fifo_needs_flush(mbox); +} +static inline mbox_msg_t mbox_fifo_readback(struct omap_mbox *mbox) +{ + return mbox->ops->fifo_readback(mbox); +} /* Mailbox IRQ handle functions */ static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) @@ -116,6 +124,33 @@ out: } EXPORT_SYMBOL(omap_mbox_msg_send); +/* + * Flush the Rx FIFO by reading back the messages + * Since the normal expectation is that the Rx will do the + * reading, add a debug message to indicate if we really flush + * + * Returns the no. of messages read back + */ +int omap_mbox_msg_rx_flush(struct omap_mbox *mbox) +{ + int ret = 0; + mbox_msg_t msg; + + while (mbox_fifo_needs_flush(mbox)) { + msg = mbox_fifo_readback(mbox); + ret++; + } + + if (ret) { + /* no more messages in the fifo. clear IRQ source. */ + ack_mbox_irq(mbox, IRQ_RX); + pr_debug("Flushed %s Rx FIFO by reading back\n", mbox->name); + } + + return ret; +} +EXPORT_SYMBOL(omap_mbox_msg_rx_flush); + static void mbox_tx_tasklet(unsigned long tx_data) { struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
On AM33XX, the mailbox module between the MPU and the WKUP-M3 co-processor facilitates a one-way communication. MPU uses the assigned mailbox sub-module to issue the interrupt to the WKUP-M3 co-processor which then goes and reads the the IPC data from registers in the control module. WKUP-M3 is in the L4_WKUP and does not have any access to the Mailbox module. Due to this limitation, the MPU is completely responsible for FIFO maintenance and interrupt generation. MPU needs to ensure that the FIFO does not overflow by reading by the assigned mailbox sub-module. This patch adds an API in the mailbox code which the MPU can use to empty the FIFO by issuing a readback command. Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com> --- arch/arm/mach-omap2/mailbox.c | 42 ++++++++++++++++++++--------- arch/arm/plat-omap/include/plat/mailbox.h | 3 ++ arch/arm/plat-omap/mailbox.c | 35 ++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 13 deletions(-)