linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] omap: mailbox: cleanup & simplify
@ 2010-04-27 17:56 Ohad Ben-Cohen
  2010-04-27 17:56 ` [PATCH 1/4] omap: mailbox cleanup: convert rwlocks to spinlock Ohad Ben-Cohen
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Ohad Ben-Cohen @ 2010-04-27 17:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Kanigeri Hari, Hiroshi Doyu, Ohad Ben-Cohen

A few simple patches that cleanup and simplifies mailbox.
The last patch is the most interesting -
It converts mailbox to use kfifo as the underlying
queueing implementation instead of using the block API.
There're also additional performance patches on the way, we
are internally testing them now.

Please review and let me know your comments.

Thanks,

Ohad Ben-Cohen (4):
  omap: mailbox cleanup: convert rwlocks to spinlock
  omap: mailbox cleanup: split MODULE_AUTHOR line
  omap: mailbox: fix reverse likeliness
  omap: mailbox: convert block api to kfifo

 arch/arm/mach-omap2/mailbox.c             |    3 +-
 arch/arm/plat-omap/include/plat/mailbox.h |    5 +-
 arch/arm/plat-omap/mailbox.c              |  135 +++++++++++++----------------
 3 files changed, 68 insertions(+), 75 deletions(-)


^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/4] omap: mailbox: convert block api to kfifo
@ 2010-05-03  9:41 Ohad Ben-Cohen
  2010-05-03 10:27 ` [PATCH " Ohad Ben-Cohen
  0 siblings, 1 reply; 20+ messages in thread
From: Ohad Ben-Cohen @ 2010-05-03  9:41 UTC (permalink / raw)
  To: Hiroshi DOYU; +Cc: linux-omap, h-kanigeri2

On Mon, May 3, 2010 at 9:07 AM, Hiroshi DOYU <Hiroshi.DOYU@nokia.com> wrote:
> From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> Subject: Re: [PATCH v2 4/4] omap: mailbox: convert block api to kfifo
> Date: Mon, 03 May 2010 08:30:36 +0300 (EEST)
>
>> Hi Ohad,
>>
>> From: ext Ohad Ben-Cohen <ohad@wizery.com>
>> Subject: [PATCH v2 4/4] omap: mailbox: convert block api to kfifo
>> Date: Sun, 2 May 2010 17:44:31 +0200
>>
>>> The underlying buffering implementation of mailbox
>>> is converted from block API to kfifo due to the simplicity
>>> and speed of kfifo.
>>>
>>> The default size of the kfifo buffer is set to 256 bytes.
>>> This value is configurable at compile time (via
>>> CONFIG_OMAP_MBOX_KFIFO_SIZE), and can be changed at
>>> runtime (via the omap_kfifo_size module parameter).
>>
>> mbox_kfifo_size?
>
> It may be also nice if there's some checking of 'mbox_kfifo_size % 4 == 0' along with 'CONFIG_OMAP_MBOX_KFIFO_SIZE % 4 == 0'?

Good point. I'll send a new patch together with this:

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index a500ac4..fb3d452 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -21,6 +21,7 @@
  *
  */

+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
@@ -394,6 +395,10 @@ static int __init omap_mbox_init(void)
        if (!mboxd)
                return -ENOMEM;

+       /* 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));
+
        return 0;
 }
 module_init(omap_mbox_init);


>
>>
>>> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
>>> Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
>>> ---
>>> If you want, you can also reach me at < ohadb at ti dot com >.
>>>
>>>  arch/arm/plat-omap/Kconfig                |    9 +++
>>>  arch/arm/plat-omap/include/plat/mailbox.h |    4 +-
>>>  arch/arm/plat-omap/mailbox.c              |  107 +++++++++++++----------------
>>>  3 files changed, 58 insertions(+), 62 deletions(-)
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 20+ messages in thread
* [PATCH 1/4] omap: mailbox: convert rwlocks to spinlock
@ 2010-05-10  9:16 Hiroshi DOYU
  2010-05-10  9:16 ` [PATCH 4/4] omap: mailbox: convert block api to kfifo Hiroshi DOYU
  0 siblings, 1 reply; 20+ messages in thread
From: Hiroshi DOYU @ 2010-05-10  9:16 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Ohad Ben-Cohen, Kanigeri Hari, Hiroshi DOYU

From: Ohad Ben-Cohen <ohad@wizery.com>

rwlocks are slower and have potential starvation issues
therefore spinlocks are generally preferred.

see also: http://lwn.net/Articles/364583/

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Kanigeri Hari <h-kanigeri2@ti.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/mailbox.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 08a2df7..af3a6ac 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -31,7 +31,7 @@
 
 static struct workqueue_struct *mboxd;
 static struct omap_mbox *mboxes;
-static DEFINE_RWLOCK(mboxes_lock);
+static DEFINE_SPINLOCK(mboxes_lock);
 
 static int mbox_configured;
 
@@ -249,16 +249,16 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 	struct omap_mbox_queue *mq;
 
 	if (likely(mbox->ops->startup)) {
-		write_lock(&mboxes_lock);
+		spin_lock(&mboxes_lock);
 		if (!mbox_configured)
 			ret = mbox->ops->startup(mbox);
 
 		if (unlikely(ret)) {
-			write_unlock(&mboxes_lock);
+			spin_unlock(&mboxes_lock);
 			return ret;
 		}
 		mbox_configured++;
-		write_unlock(&mboxes_lock);
+		spin_unlock(&mboxes_lock);
 	}
 
 	ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
@@ -304,12 +304,12 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
 	free_irq(mbox->irq, mbox);
 
 	if (unlikely(mbox->ops->shutdown)) {
-		write_lock(&mboxes_lock);
+		spin_lock(&mboxes_lock);
 		if (mbox_configured > 0)
 			mbox_configured--;
 		if (!mbox_configured)
 			mbox->ops->shutdown(mbox);
-		write_unlock(&mboxes_lock);
+		spin_unlock(&mboxes_lock);
 	}
 }
 
@@ -330,14 +330,14 @@ struct omap_mbox *omap_mbox_get(const char *name)
 	struct omap_mbox *mbox;
 	int ret;
 
-	read_lock(&mboxes_lock);
+	spin_lock(&mboxes_lock);
 	mbox = *(find_mboxes(name));
 	if (mbox == NULL) {
-		read_unlock(&mboxes_lock);
+		spin_unlock(&mboxes_lock);
 		return ERR_PTR(-ENOENT);
 	}
 
-	read_unlock(&mboxes_lock);
+	spin_unlock(&mboxes_lock);
 
 	ret = omap_mbox_startup(mbox);
 	if (ret)
@@ -363,15 +363,15 @@ int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 	if (mbox->next)
 		return -EBUSY;
 
-	write_lock(&mboxes_lock);
+	spin_lock(&mboxes_lock);
 	tmp = find_mboxes(mbox->name);
 	if (*tmp) {
 		ret = -EBUSY;
-		write_unlock(&mboxes_lock);
+		spin_unlock(&mboxes_lock);
 		goto err_find;
 	}
 	*tmp = mbox;
-	write_unlock(&mboxes_lock);
+	spin_unlock(&mboxes_lock);
 
 	return 0;
 
@@ -384,18 +384,18 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
 {
 	struct omap_mbox **tmp;
 
-	write_lock(&mboxes_lock);
+	spin_lock(&mboxes_lock);
 	tmp = &mboxes;
 	while (*tmp) {
 		if (mbox == *tmp) {
 			*tmp = mbox->next;
 			mbox->next = NULL;
-			write_unlock(&mboxes_lock);
+			spin_unlock(&mboxes_lock);
 			return 0;
 		}
 		tmp = &(*tmp)->next;
 	}
-	write_unlock(&mboxes_lock);
+	spin_unlock(&mboxes_lock);
 
 	return -EINVAL;
 }
-- 
1.7.1.rc1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-05-10  9:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-27 17:56 [PATCH 0/4] omap: mailbox: cleanup & simplify Ohad Ben-Cohen
2010-04-27 17:56 ` [PATCH 1/4] omap: mailbox cleanup: convert rwlocks to spinlock Ohad Ben-Cohen
2010-04-28  7:50   ` Hiroshi DOYU
2010-04-28 10:41     ` Ohad Ben-Cohen
2010-04-29 12:44   ` Kanigeri, Hari
2010-04-29 13:14     ` Ohad Ben-Cohen
2010-04-29 13:35       ` Ohad Ben-Cohen
2010-04-27 17:56 ` [PATCH 2/4] omap: mailbox cleanup: split MODULE_AUTHOR line Ohad Ben-Cohen
2010-04-27 17:56 ` [PATCH 3/4] omap: mailbox: fix reverse likeliness Ohad Ben-Cohen
2010-04-27 17:56 ` [PATCH 4/4] omap: mailbox: convert block api to kfifo Ohad Ben-Cohen
2010-04-28  5:52   ` Hiroshi DOYU
2010-04-28 11:02     ` Ohad Ben-Cohen
2010-04-28 11:16       ` Hiroshi DOYU
2010-04-28 11:25         ` Ohad Ben-Cohen
2010-04-28 11:52           ` Hiroshi DOYU
2010-04-28 12:03             ` Ohad Ben-Cohen
2010-04-28  5:56   ` Hiroshi DOYU
2010-04-28 11:02     ` Ohad Ben-Cohen
  -- strict thread matches above, loose matches on Subject: below --
2010-05-03  9:41 [PATCH v2 " Ohad Ben-Cohen
2010-05-03 10:27 ` [PATCH " Ohad Ben-Cohen
2010-05-10  9:16 [PATCH 1/4] omap: mailbox: convert rwlocks to spinlock Hiroshi DOYU
2010-05-10  9:16 ` [PATCH 4/4] omap: mailbox: convert block api to kfifo Hiroshi DOYU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).