Skip to contentSkip to conversation

omap:mailbox-enhancements and fixes

PATCH Superseded Hari Kanigeri 6 participants 16 messages Nov 10, 2010 – Nov 11, 2010

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover omap:mailbox-enhancements and fixes

Thanks to Rene Sapiens and Omar Ramirez for their inputs on initial patch set.
http://www.mail-archive.com/[email protected]/msg37278.html

The patch set addresses the following review comments from Rene and Omar.
http://www.mail-archive.com/[email protected]/msg37626.html
https://patchwork.kernel.org/patch/255091/
https://patchwork.kernel.org/patch/255081/

Following patches are changed because of above review comments:
omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers

Following patch is dropped from initial patch set
omap:mailbox-resolve multiple receiver problem

The patch set is tested on omap4 SDP board.

Fernando Guzman Lugo (1):
mailbox: change full flag per mailbox queue instead of global

Hari Kanigeri (5):
omap:mailbox: fix rx interrupt disable in omap4 omap:mailbox-fix checkpatch warnings omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers omap:clocks44x-add dummy clock for mailbox

 arch/arm/mach-omap2/clock44xx_data.c      |    1 +
 arch/arm/mach-omap2/mailbox.c             |    5 +-
 arch/arm/plat-omap/include/plat/mailbox.h |    8 +-
 arch/arm/plat-omap/mailbox.c              |  127 +++++++++++++++++------------
 4 files changed, 83 insertions(+), 58 deletions(-)
#1 lore raw

PATCH v2 1/6 mailbox: change full flag per mailbox queue instead of global

From: Fernando Guzman Lugo <[email protected]>

As pointed by Ohad Ben-Cohen, the variable rq_full flag is a global variable, so if there are multiple mailbox users there will be conflics. Now there is a full flag per mailbox queue.

Version 2:
- Rebase to the latest.
Version 3:
- Remove spin_lock protection. When the full flag is true the interrupt for that mailbox is disabled. So there is no race condition if full flag is modified before calling omap_mbox_enable_irq.

---
 arch/arm/plat-omap/include/plat/mailbox.h |    1 +
 arch/arm/plat-omap/mailbox.c              |    7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +1 -0
index 9976565..13f2ef3 100644
@@ -48,6 +48,7 @@ struct omap_mbox_queue {
 	struct tasklet_struct	tasklet;
 	int	(*callback)(void *);
 	struct omap_mbox	*mbox;
+	bool full;
 };
 
 struct omap_mbox {
arch/arm/plat-omap/mailbox.c +5 -2
index d2fafb8..9ce3570 100644
@@ -33,7 +33,6 @@
 
 static struct workqueue_struct *mboxd;
 static struct omap_mbox **mboxes;
-static bool rq_full;
 
 static int mbox_configured;
 static DEFINE_MUTEX(mbox_configured_lock);
@@ -148,6 +147,10 @@ static void mbox_rx_work(struct work_struct *work)
 
 		if (mq->callback)
 			mq->callback((void *)msg);
+		if (mq->full) {
+			mq->full = false;
+			omap_mbox_enable_irq(mq->mbox, IRQ_RX);
+		}
 	}
 }
 
@@ -170,7 +173,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 	while (!mbox_fifo_empty(mbox)) {
 		if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
 			omap_mbox_disable_irq(mbox, IRQ_RX);
-			rq_full = true;
+			mq->full = true;
 			goto nomem;
 		}
 
Signature · 1 line
1.7.0
#2 lore raw

PATCH v2 2/6 omap:mailbox: fix rx interrupt disable in omap4

In reply to Hari Kanigeri

disabling rx interrupt on omap4 is different than its pre-decessors. The bit in OMAP4_MAILBOX_IRQENABLE_CLR should be set to disable the interrupts instead of clearing the bit.

---
 arch/arm/mach-omap2/mailbox.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/mailbox.c +4 -1
index 42dbfa4..82b5ced 100644
@@ -195,7 +195,10 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
 	struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv;
 	u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
 	l = mbox_read_reg(p->irqdisable);
-	l &= ~bit;
+	if (cpu_is_omap44xx())
+		l |= bit;
+	else
+		l &= ~bit;
 	mbox_write_reg(l, p->irqdisable);
 }
 
Signature · 1 line
1.7.0
#3 lore raw

PATCH v2 3/6 omap:mailbox-fix checkpatch warnings

In reply to Hari Kanigeri

Fix the checkpatch warnings observed in mailbox module

---
 arch/arm/plat-omap/mailbox.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/plat-omap/mailbox.c +5 -4
index 9ce3570..ed960c1 100644
@@ -279,11 +279,11 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 
 	return 0;
 
- fail_alloc_rxq:
+fail_alloc_rxq:
 	mbox_queue_free(mbox->txq);
- fail_alloc_txq:
+fail_alloc_txq:
 	free_irq(mbox->irq, mbox);
- fail_request_irq:
+fail_request_irq:
 	if (mbox->ops->shutdown)
 		mbox->ops->shutdown(mbox);
 
@@ -394,7 +394,8 @@ static int __init omap_mbox_init(void)
 
 	/* kfifo size sanity check: alignment and minimal size */
 	mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
-	mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t));
+	mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
+						sizeof(mbox_msg_t));
 
 	return 0;
 }
Signature · 1 line
1.7.0
#4 lore raw

PATCH 3/6 omap:mailbox-fix checkpatch warnings

Hello.

Quoted 11 lines · Hari Kanigeri

Fix the checkpatch warnings observed in mailbox module

---
 arch/arm/plat-omap/mailbox.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/plat-omap/mailbox.c +0 -0
index 9ce3570..ed960c1 100644

[...]

arch/arm/plat-omap/mailbox.c static int __init omap_mbox_init(void) · line 398

Quoted 7 lines
arch/arm/plat-omap/mailbox.c +2 -1
@@ -394,7 +394,8 @@ static int __init omap_mbox_init(void)
 
 	/* kfifo size sanity check: alignment and minimal size */
 	mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
-	mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t));
+	mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
+						sizeof(mbox_msg_t));

This line is over-indented a bit.

WBR, Sergei

#5 lore raw

PATCH v2 4/6 omap:mailbox-send message in process context

In reply to Hari Kanigeri

Schedule the Tasklet to send only when mailbox fifo is full and there are pending messages in kifo, else send the message directly in the Process context. This would avoid needless scheduling of Tasklet for every message transfer

---
 arch/arm/plat-omap/mailbox.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
arch/arm/plat-omap/mailbox.c +7 -2
index ed960c1..e353e26 100644
@@ -92,20 +92,25 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 	struct omap_mbox_queue *mq = mbox->txq;
 	int ret = 0, len;
 
-	spin_lock(&mq->lock);
+	spin_lock_bh(&mq->lock);
 
 	if (kfifo_avail(&mq->fifo) < sizeof(msg)) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
+	if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) {
+		mbox_fifo_write(mbox, msg);
+		goto out;
+	}
+
 	len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
 	WARN_ON(len != sizeof(msg));
 
 	tasklet_schedule(&mbox->txq->tasklet);
 
 out:
-	spin_unlock(&mq->lock);
+	spin_unlock_bh(&mq->lock);
 	return ret;
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);
Signature · 1 line
1.7.0
#6 lore raw

PATCH v2 5/6 omap:mailbox-add notification support for multiple readers

In reply to Hari Kanigeri

In the current mailbox driver, the mailbox internal pointer for callback can be directly manipulated by the Users, so a second User can easily corrupt the first user's callback pointer. The initial effort to correct this issue can be referred here:
https://patchwork.kernel.org/patch/107520/

Along with fixing the above stated issue, this patch adds the flexibility option to register notifications from multiple readers to the events received on a mailbox instance. The discussion regarding this can be referred here.
http://www.mail-archive.com/[email protected]/msg30671.html

---
 arch/arm/plat-omap/include/plat/mailbox.h |    7 +-
 arch/arm/plat-omap/mailbox.c              |  102 ++++++++++++++++-------------
 2 files changed, 60 insertions(+), 49 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +4 -3
index 13f2ef3..cc3921e 100644
@@ -46,7 +46,6 @@ struct omap_mbox_queue {
 	struct kfifo		fifo;
 	struct work_struct	work;
 	struct tasklet_struct	tasklet;
-	int	(*callback)(void *);
 	struct omap_mbox	*mbox;
 	bool full;
 };
@@ -58,13 +57,15 @@ struct omap_mbox {
 	struct omap_mbox_ops	*ops;
 	struct device		*dev;
 	void			*priv;
+	int			use_count;
+	struct blocking_notifier_head   notifier;
 };
 
 int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
 void omap_mbox_init_seq(struct omap_mbox *);
 
-struct omap_mbox *omap_mbox_get(const char *);
-void omap_mbox_put(struct omap_mbox *);
+struct omap_mbox *omap_mbox_get(const char *, struct notifier_block *nb);
+void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb);
 
 int omap_mbox_register(struct device *parent, struct omap_mbox **);
 int omap_mbox_unregister(void);
arch/arm/plat-omap/mailbox.c +56 -46

158 lines not on this page · raw message

Signature · 1 line
1.7.0
#7 lore raw

PATCH v2 6/6 omap:clocks44x-add dummy clock for mailbox

In reply to Hari Kanigeri

In omap4, there is no explicit configuration register to enable mailbox clocks. Defining dummy clock for mailbox clock module to keep the mailbox driver backward compatible with previous omaps.

---
 arch/arm/mach-omap2/clock44xx_data.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clock44xx_data.c +1 -0
index e10db7a..421ae7f 100644
@@ -2687,6 +2687,7 @@ static struct omap_clk omap44xx_clks[] = {
 	CLK(NULL,	"uart3_ick",			&dummy_ck,	CK_443X),
 	CLK(NULL,	"uart4_ick",			&dummy_ck,	CK_443X),
 	CLK("omap_wdt",	"ick",				&dummy_ck,	CK_443X),
+	CLK(NULL,	"mailboxes_ick",		&dummy_ck,	CK_443X),
 };
 
 int __init omap4xxx_clk_init(void)
Signature · 1 line
1.7.0
maintainer
#8 lore raw

PATCH 6/6 omap:clocks44x-add dummy clock for mailbox

Hello Hari

Quoted 3 lines · Hari Kanigeri

In omap4, there is no explicit configuration register to enable mailbox clocks. Defining dummy clock for mailbox clock module to keep the mailbox driver backward compatible with previous omaps.

If you split this off from the rest of your series, I'll queue it for .38.

- Paul

#9 lore raw

PATCH v2 6/6 omap:clocks44x-add dummy clock for mailbox

Paul,

Quoted 10 lines · Paul Walmsley

Hello Hari

Quoted 3 lines · Hari Kanigeri

In omap4, there is no explicit configuration register to enable mailbox clocks. Defining dummy clock for mailbox clock module to keep the mailbox driver backward compatible with previous omaps.

If you split this off from the rest of your series, I'll queue it for .38.

Thanks. I will send this patch separately.

Best regards,
Hari

#10 lore raw

v2 cover omap:mailbox-enhancements and fixes

In reply to Hari Kanigeri

Hi Hari,

Quoted 16 lines · Hari Kanigeri

Thanks to Rene Sapiens and Omar Ramirez for their inputs on initial patch set.
http://www.mail-archive.com/[email protected]/msg37278.html

The patch set addresses the following review comments from Rene and Omar.
http://www.mail-archive.com/[email protected]/msg37626.html
https://patchwork.kernel.org/patch/255091/
https://patchwork.kernel.org/patch/255081/

Following patches are changed because of above review comments:
omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers

Following patch is dropped from initial patch set
omap:mailbox-resolve multiple receiver problem

Quoted 8 lines

The patch set is tested on omap4 SDP board.

Fernando Guzman Lugo (1):
mailbox: change full flag per mailbox queue instead of global

Hari Kanigeri (5):
omap:mailbox: fix rx interrupt disable in omap4 omap:mailbox-fix checkpatch warnings

That one is weird? How can you submit a patch that fix checkpatch?
In theory you should not send any patch that generate checkpatch error or warning.

Quoted 3 lines

omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers omap:clocks44x-add dummy clock for mailbox

We are trying to enforce some consistency in the subjects name so you should name your patches like that:

OMAP: mailbox: fix rx interrupt disable in omap4
OMAP: mailbox: fix checkpatch warnings
OMAP: mailbox: send message in process context
OMAP: mailbox: add notification support for multiple readers
OMAP4: clocks: add dummy clock for mailbox

Regards,
Benoit

#11 lore raw

v2 cover omap:mailbox-enhancements and fixes

Benoit,

Thanks for your comments.

Quoted 22 lines · Benoit

Hi Hari,

Quoted 19 lines · Hari Kanigeri

Thanks to Rene Sapiens and Omar Ramirez for their inputs on initial patch set.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg37278.html

The patch set addresses the following review comments from Rene and Omar.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg37626.html
https://patchwork.kernel.org/patch/255091/
https://patchwork.kernel.org/patch/255081/

Following patches are changed because of above review comments:
omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers

Following patch is dropped from initial patch set
omap:mailbox-resolve multiple receiver problem

The patch set is tested on omap4 SDP board.

Quoted 8 lines
Quoted 6 lines

Fernando Guzman Lugo (1):
? mailbox: change full flag per mailbox queue instead of global

Hari Kanigeri (5):
? omap:mailbox: fix rx interrupt disable in omap4
? omap:mailbox-fix checkpatch warnings

That one is weird? How can you submit a patch that fix checkpatch?

Why weird if the patch is fixing the checkpatch warnings that were already present in the code ?
The other option is to leave the checkpatch warnings in the code :)

Quoted 9 lines

In theory you should not send any patch that generate checkpatch error or warning.

Quoted 3 lines

? omap:mailbox-send message in process context
? omap:mailbox-add notification support for multiple readers ? omap:clocks44x-add dummy clock for mailbox

We are trying to enforce some consistency in the subjects name so you should name your patches like that:

Good point, thanks for pointing about consistency. I wasn't aware about the rule to use OMAP in caps.
I will fix it.

Thank you,
Best regards,
Hari

#12 lore raw

v2 cover omap:mailbox-enhancements and fixes

Quoted 30 lines · Hari Kanigeri

Benoit,

Thanks for your comments.

Quoted 25 lines · Benoit

Hi Hari,

Quoted 22 lines · Hari Kanigeri

Thanks to Rene Sapiens and Omar Ramirez for their inputs on initial patch set.
http://www.mail-archive.com/[email protected]/msg37278.html

The patch set addresses the following review comments from Rene and Omar.
http://www.mail-archive.com/[email protected]/msg37626.html
https://patchwork.kernel.org/patch/255091/
https://patchwork.kernel.org/patch/255081/

Following patches are changed because of above review comments:
omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers

Following patch is dropped from initial patch set
omap:mailbox-resolve multiple receiver problem

The patch set is tested on omap4 SDP board.

Fernando Guzman Lugo (1):
mailbox: change full flag per mailbox queue instead of global

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Hari Kanigeri (5):
omap:mailbox: fix rx interrupt disable in omap4 omap:mailbox-fix checkpatch warnings

That one is weird? How can you submit a patch that fix checkpatch?

Why weird if the patch is fixing the checkpatch warnings that were already present in the code ?

OK, so you meant that this is fixing some already existing warnings in mainline code?
My point was that checkpatch is supposed to check patch... but it's true that is can check the code as well. I was assuming that all the code in mainline is supposed to be already checkpatch proof :-) It seems that this is not the case.

It might be interesting to run it on every plat-omap / mach-omap files...

Thanks,
Benoit

Quoted 19 lines

The other option is to leave the checkpatch warnings in the code :)

Quoted 9 lines

In theory you should not send any patch that generate checkpatch error or warning.

Quoted 3 lines

omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers omap:clocks44x-add dummy clock for mailbox

We are trying to enforce some consistency in the subjects name so you should name your patches like that:

Good point, thanks for pointing about consistency. I wasn't aware about the rule to use OMAP in caps.
I will fix it.

Thank you,
Best regards,
Hari

#13 lore raw

v2 cover omap:mailbox-enhancements and fixes

Hi,

Quoted 6 lines · Benoit

My point was that checkpatch is supposed to check patch... but it's true that is can check the code as well. I was assuming that all the code in mainline is supposed to be already checkpatch proof :-)
It seems that this is not the case.

It might be interesting to run it on every plat-omap / mach-omap files...

you might be surprised with the results :-)

Signature · 1 line
balbi
#14 lore raw

v2 cover omap:mailbox-enhancements and fixes

In reply to Hari Kanigeri

On 11/10/2010 5:56 PM, Hari Kanigeri wrote:

[...]

Quoted 2 lines

Good point, thanks for pointing about consistency. I wasn't aware about the rule to use OMAP in caps.

Well, I'm not sure there is any rule like that, it is just what was mostly used so far. My point was more about the text after the omap.

Benoit

#15 lore raw

v2 cover omap:mailbox-enhancements and fixes

In reply to Hari Kanigeri

Hari,

I forgot one comment. Since this series is a v2, every patches subject should contain the [PATCH v2 x/6].

FYI, patchwork will not track the cover letter, so we will miss that version information in the real patches.

I forgot as well this subject:
mailbox: change full flag per mailbox queue instead of global

Should be
OMAP: mailbox: change full flag per mailbox queue instead of global

Since it is purely omap stuff.

Regards,
Benoit

Quoted 38 lines · Hari Kanigeri

Thanks to Rene Sapiens and Omar Ramirez for their inputs on initial patch set.
http://www.mail-archive.com/[email protected]/msg37278.html

The patch set addresses the following review comments from Rene and Omar.
http://www.mail-archive.com/[email protected]/msg37626.html
https://patchwork.kernel.org/patch/255091/
https://patchwork.kernel.org/patch/255081/

Following patches are changed because of above review comments:
omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers

Following patch is dropped from initial patch set
omap:mailbox-resolve multiple receiver problem

The patch set is tested on omap4 SDP board.

Fernando Guzman Lugo (1):
mailbox: change full flag per mailbox queue instead of global

Hari Kanigeri (5):
omap:mailbox: fix rx interrupt disable in omap4 omap:mailbox-fix checkpatch warnings omap:mailbox-send message in process context omap:mailbox-add notification support for multiple readers omap:clocks44x-add dummy clock for mailbox

  arch/arm/mach-omap2/clock44xx_data.c      |    1 +
  arch/arm/mach-omap2/mailbox.c             |    5 +-
  arch/arm/plat-omap/include/plat/mailbox.h |    8 +-
  arch/arm/plat-omap/mailbox.c              |  127 +++++++++++++++++------------
  4 files changed, 83 insertions(+), 58 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html