linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
@ 2009-09-04 11:48 C.A, Subramaniam
  2009-09-07  8:49 ` Hiroshi DOYU
  0 siblings, 1 reply; 21+ messages in thread
From: C.A, Subramaniam @ 2009-09-04 11:48 UTC (permalink / raw)
  To: linux-omap@vger.kernel.org
  Cc: tony@atomide.com, Hiroshi.DOYU@nokia.com, rmk@arm.linux.org.uk,
	Kanigeri, Hari, Gupta, Ramesh

>From e759173e77f73fabce5177b4f685df20b16c6922 Mon Sep 17 00:00:00 2001
From: C A Subramaniam <subramaniam.ca@ti.com>
Date: Thu, 3 Sep 2009 17:42:35 +0530
Subject: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet
   implementation

This patch uses a tasklet implementation for
sending mailbox messages.

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
---
 arch/arm/mach-omap2/mailbox.c             |   43 ++++++++++-----
 arch/arm/plat-omap/include/mach/mailbox.h |   16 +++++-
 arch/arm/plat-omap/mailbox.c              |   80 ++++++++++++++---------------
 3 files changed, 81 insertions(+), 58 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 52a1670..45aea98 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -236,6 +237,17 @@ static struct omap_mbox_ops omap2_mbox_ops = {
 	.restore_ctx	= omap2_mbox_restore_ctx,
 };
 
+
+static struct omap_mbox_task omap_mbox_1_tasklet = {
+	.arg	= NULL,
+};
+
+static struct omap_mbox_task omap_mbox_2_tasklet = {
+	.arg	= NULL,
+};
+
+
+
 /*
  * MAILBOX 0: ARM -> DSP,
  * MAILBOX 1: ARM <- DSP.
@@ -272,6 +284,7 @@ struct omap_mbox mbox_1_info = {
 	.name	= "mailbox-1",
 	.ops	= &omap2_mbox_ops,
 	.priv	= &omap2_mbox_1_priv,
+	.tx_tasklet = &omap_mbox_1_tasklet,
 };
 EXPORT_SYMBOL(mbox_1_info);
 #else
@@ -305,8 +318,10 @@ struct omap_mbox mbox_2_info = {
 	.name	= "mailbox-2",
 	.ops	= &omap2_mbox_ops,
 	.priv	= &omap2_mbox_2_priv,
+	.tx_tasklet = &omap_mbox_2_tasklet,
 };
 EXPORT_SYMBOL(mbox_2_info);
+
 #endif
 
 
diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index bf06953..5271345 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -28,8 +28,10 @@ struct omap_mbox_ops {
 	int		(*fifo_empty)(struct omap_mbox *mbox);
 	int		(*fifo_full)(struct omap_mbox *mbox);
 	/* irq */
-	void		(*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
-	void		(*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+	void		(*enable_irq)(struct omap_mbox *mbox,
+						omap_mbox_irq_t irq);
+	void		(*disable_irq)(struct omap_mbox *mbox,
+						omap_mbox_irq_t irq);
 	void		(*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	int		(*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	/* ctx */
@@ -45,12 +47,22 @@ struct omap_mbox_queue {
 	struct omap_mbox	*mbox;
 };
 
+struct omap_mbox_task{
+	spinlock_t		lock;
+	struct tasklet_struct	*t;
+	mbox_msg_t		msg;
+	void			*arg;
+};
+
+
 struct omap_mbox {
 	char			*name;
 	unsigned int		irq;
 
 	struct omap_mbox_queue	*txq, *rxq;
 
+	struct omap_mbox_task	*tx_tasklet;
+
 	struct omap_mbox_ops	*ops;
 
 	mbox_msg_t		seq_snd, seq_rcv;
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 84cf6af..b5e53d4 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -63,60 +63,49 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
 /*
  * message sender
  */
-static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
+static void __mbox_msg_send(unsigned long tx)
 {
+	struct omap_mbox_task *tx_data  =  (struct omap_mbox_task *)tx;
+	struct omap_mbox *mbox = (struct omap_mbox *)tx_data->arg;
+	mbox_msg_t msg = tx_data->msg;
 	int ret = 0, i = 1000;
 
 	while (mbox_fifo_full(mbox)) {
-		if (mbox->ops->type == OMAP_MBOX_TYPE2)
-			return -1;
-		if (--i == 0)
-			return -1;
+		if (mbox->ops->type == OMAP_MBOX_TYPE2) {
+			printk(KERN_ERR "Invalid mailbox type\n");
+			return ;
+		}
+		if (--i == 0) {
+			printk(KERN_ERR "Time out writing to mailbox\n");
+			return ;
+		}
 		udelay(1);
 	}
 	mbox_fifo_write(mbox, msg);
-	return ret;
-}
-
-struct omap_msg_tx_data {
-	mbox_msg_t	msg;
-	void		*arg;
-};
+	tx_data->arg = NULL;
+	spin_unlock(&(mbox->tx_tasklet->lock));
 
-static void omap_msg_tx_end_io(struct request *rq, int error)
-{
-	kfree(rq->special);
-	__blk_put_request(rq->q, rq);
+	return;
 }
 
+
 int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 {
-	struct omap_msg_tx_data *tx_data;
-	struct request *rq;
-	struct request_queue *q = mbox->txq->queue;
+	struct omap_mbox_task *tx_task = mbox->tx_tasklet;
 
-	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
-	if (unlikely(!tx_data))
-		return -ENOMEM;
-
-	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
-	if (unlikely(!rq)) {
-		kfree(tx_data);
-		return -ENOMEM;
-	}
+	spin_lock(&(mbox->tx_tasklet->lock));
+	tx_task->arg = (void *)mbox;
+	tx_task->msg = msg;
 
-	tx_data->msg = msg;
-	rq->end_io = omap_msg_tx_end_io;
-	blk_insert_request(q, rq, 0, tx_data);
+	tasklet_schedule(tx_task->t);
 
-	schedule_work(&mbox->txq->work);
 	return 0;
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);
 
 static void mbox_tx_work(struct work_struct *work)
 {
-	int ret;
+	int ret = 0;
 	struct request *rq;
 	struct omap_mbox_queue *mq = container_of(work,
 				struct omap_mbox_queue, work);
@@ -124,8 +113,6 @@ static void mbox_tx_work(struct work_struct *work)
 	struct request_queue *q = mbox->txq->queue;
 
 	while (1) {
-		struct omap_msg_tx_data *tx_data;
-
 		spin_lock(q->queue_lock);
 		rq = blk_fetch_request(q);
 		spin_unlock(q->queue_lock);
@@ -133,9 +120,6 @@ static void mbox_tx_work(struct work_struct *work)
 		if (!rq)
 			break;
 
-		tx_data = rq->special;
-
-		ret = __mbox_msg_send(mbox, tx_data->msg);
 		if (ret) {
 			omap_mbox_enable_irq(mbox, IRQ_TX);
 			spin_lock(q->queue_lock);
@@ -206,7 +190,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 			goto nomem;
 
 		msg = mbox_fifo_read(mbox);
-
+		rq->special = (void *)msg;
 
 		blk_insert_request(q, rq, 0, (void *)msg);
 		if (mbox->ops->type == OMAP_MBOX_TYPE1)
@@ -298,13 +282,25 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 	}
 	mbox->rxq = mq;
 
+	mbox->tx_tasklet->t =  kzalloc(sizeof(struct tasklet_struct),
+					GFP_KERNEL);
+	if (!mbox->tx_tasklet->t) {
+		ret = -ENOMEM;
+		goto fail_alloc_tasklet;
+	}
+	spin_lock_init(&mbox->tx_tasklet->lock);
+	tasklet_init(mbox->tx_tasklet->t, __mbox_msg_send,
+				(unsigned long)mbox->tx_tasklet);
+
 	return 0;
 
- fail_alloc_rxq:
+fail_alloc_tasklet:
+	mbox_queue_free(mbox->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 (unlikely(mbox->ops->shutdown))
 		mbox->ops->shutdown(mbox);
 
-- 
1.5.3.2

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

* Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-04 11:48 C.A, Subramaniam
@ 2009-09-07  8:49 ` Hiroshi DOYU
  2009-09-08 17:43   ` C.A, Subramaniam
  0 siblings, 1 reply; 21+ messages in thread
From: Hiroshi DOYU @ 2009-09-07  8:49 UTC (permalink / raw)
  To: subramaniam.ca; +Cc: linux-omap, tony, rmk, h-kanigeri2, grgupta

From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
Subject: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
Date: Fri, 4 Sep 2009 13:48:45 +0200

> From e759173e77f73fabce5177b4f685df20b16c6922 Mon Sep 17 00:00:00 2001
> From: C A Subramaniam <subramaniam.ca@ti.com>
> Date: Thu, 3 Sep 2009 17:42:35 +0530
> Subject: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet
>    implementation
> 
> This patch uses a tasklet implementation for
> sending mailbox messages.
> 
> Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
> Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
> ---
>  arch/arm/mach-omap2/mailbox.c             |   43 ++++++++++-----
>  arch/arm/plat-omap/include/mach/mailbox.h |   16 +++++-
>  arch/arm/plat-omap/mailbox.c              |   80 ++++++++++++++---------------
>  3 files changed, 81 insertions(+), 58 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 52a1670..45aea98 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -236,6 +237,17 @@ static struct omap_mbox_ops omap2_mbox_ops = {
>  	.restore_ctx	= omap2_mbox_restore_ctx,
>  };
>  
> +
> +static struct omap_mbox_task omap_mbox_1_tasklet = {
> +	.arg	= NULL,
> +};
> +
> +static struct omap_mbox_task omap_mbox_2_tasklet = {
> +	.arg	= NULL,
> +};

As I described in the comment on [PATCH 8/10], I think that it would
be better to keep "mach-omap2/mailbox.c" simple and to add some
additional logic on "plat-omap/mailbox.c".

Would it be possbile to move this tasklet implementation to
"plat-omap/mailbox.c"?

> +
> +
> +
>  /*
>   * MAILBOX 0: ARM -> DSP,
>   * MAILBOX 1: ARM <- DSP.
> @@ -272,6 +284,7 @@ struct omap_mbox mbox_1_info = {
>  	.name	= "mailbox-1",
>  	.ops	= &omap2_mbox_ops,
>  	.priv	= &omap2_mbox_1_priv,
> +	.tx_tasklet = &omap_mbox_1_tasklet,
>  };
>  EXPORT_SYMBOL(mbox_1_info);
>  #else
> @@ -305,8 +318,10 @@ struct omap_mbox mbox_2_info = {
>  	.name	= "mailbox-2",
>  	.ops	= &omap2_mbox_ops,
>  	.priv	= &omap2_mbox_2_priv,
> +	.tx_tasklet = &omap_mbox_2_tasklet,
>  };
>  EXPORT_SYMBOL(mbox_2_info);
> +
>  #endif
>  
>  
> diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
> index bf06953..5271345 100644
> --- a/arch/arm/plat-omap/include/mach/mailbox.h
> +++ b/arch/arm/plat-omap/include/mach/mailbox.h
> @@ -28,8 +28,10 @@ struct omap_mbox_ops {
>  	int		(*fifo_empty)(struct omap_mbox *mbox);
>  	int		(*fifo_full)(struct omap_mbox *mbox);
>  	/* irq */
> -	void		(*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
> -	void		(*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
> +	void		(*enable_irq)(struct omap_mbox *mbox,
> +						omap_mbox_irq_t irq);
> +	void		(*disable_irq)(struct omap_mbox *mbox,
> +						omap_mbox_irq_t irq);
>  	void		(*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
>  	int		(*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
>  	/* ctx */
> @@ -45,12 +47,22 @@ struct omap_mbox_queue {
>  	struct omap_mbox	*mbox;
>  };
>  
> +struct omap_mbox_task{
> +	spinlock_t		lock;
> +	struct tasklet_struct	*t;
> +	mbox_msg_t		msg;
> +	void			*arg;
> +};
> +
> +
>  struct omap_mbox {
>  	char			*name;
>  	unsigned int		irq;
>  
>  	struct omap_mbox_queue	*txq, *rxq;
>  
> +	struct omap_mbox_task	*tx_tasklet;
> +
>  	struct omap_mbox_ops	*ops;
>  
>  	mbox_msg_t		seq_snd, seq_rcv;
> diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
> index 84cf6af..b5e53d4 100644
> --- a/arch/arm/plat-omap/mailbox.c
> +++ b/arch/arm/plat-omap/mailbox.c
> @@ -63,60 +63,49 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
>  /*
>   * message sender
>   */
> -static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
> +static void __mbox_msg_send(unsigned long tx)
>  {
> +	struct omap_mbox_task *tx_data  =  (struct omap_mbox_task *)tx;
> +	struct omap_mbox *mbox = (struct omap_mbox *)tx_data->arg;
> +	mbox_msg_t msg = tx_data->msg;
>  	int ret = 0, i = 1000;
>  
>  	while (mbox_fifo_full(mbox)) {
> -		if (mbox->ops->type == OMAP_MBOX_TYPE2)
> -			return -1;
> -		if (--i == 0)
> -			return -1;
> +		if (mbox->ops->type == OMAP_MBOX_TYPE2) {
> +			printk(KERN_ERR "Invalid mailbox type\n");
> +			return ;
> +		}
> +		if (--i == 0) {
> +			printk(KERN_ERR "Time out writing to mailbox\n");
> +			return ;
> +		}
>  		udelay(1);
>  	}
>  	mbox_fifo_write(mbox, msg);
> -	return ret;
> -}
> -
> -struct omap_msg_tx_data {
> -	mbox_msg_t	msg;
> -	void		*arg;
> -};
> +	tx_data->arg = NULL;
> +	spin_unlock(&(mbox->tx_tasklet->lock));
>  
> -static void omap_msg_tx_end_io(struct request *rq, int error)
> -{
> -	kfree(rq->special);
> -	__blk_put_request(rq->q, rq);
> +	return;
>  }
>  
> +
>  int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
>  {
> -	struct omap_msg_tx_data *tx_data;
> -	struct request *rq;
> -	struct request_queue *q = mbox->txq->queue;
> +	struct omap_mbox_task *tx_task = mbox->tx_tasklet;
>  
> -	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
> -	if (unlikely(!tx_data))
> -		return -ENOMEM;
> -
> -	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
> -	if (unlikely(!rq)) {
> -		kfree(tx_data);
> -		return -ENOMEM;
> -	}
> +	spin_lock(&(mbox->tx_tasklet->lock));
> +	tx_task->arg = (void *)mbox;
> +	tx_task->msg = msg;
>  
> -	tx_data->msg = msg;
> -	rq->end_io = omap_msg_tx_end_io;
> -	blk_insert_request(q, rq, 0, tx_data);
> +	tasklet_schedule(tx_task->t);
>  
> -	schedule_work(&mbox->txq->work);
>  	return 0;
>  }
>  EXPORT_SYMBOL(omap_mbox_msg_send);
>  
>  static void mbox_tx_work(struct work_struct *work)
>  {
> -	int ret;
> +	int ret = 0;
>  	struct request *rq;
>  	struct omap_mbox_queue *mq = container_of(work,
>  				struct omap_mbox_queue, work);
> @@ -124,8 +113,6 @@ static void mbox_tx_work(struct work_struct *work)
>  	struct request_queue *q = mbox->txq->queue;
>  
>  	while (1) {
> -		struct omap_msg_tx_data *tx_data;
> -
>  		spin_lock(q->queue_lock);
>  		rq = blk_fetch_request(q);
>  		spin_unlock(q->queue_lock);
> @@ -133,9 +120,6 @@ static void mbox_tx_work(struct work_struct *work)
>  		if (!rq)
>  			break;
>  
> -		tx_data = rq->special;
> -
> -		ret = __mbox_msg_send(mbox, tx_data->msg);
>  		if (ret) {
>  			omap_mbox_enable_irq(mbox, IRQ_TX);
>  			spin_lock(q->queue_lock);
> @@ -206,7 +190,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
>  			goto nomem;
>  
>  		msg = mbox_fifo_read(mbox);
> -
> +		rq->special = (void *)msg;
>  
>  		blk_insert_request(q, rq, 0, (void *)msg);
>  		if (mbox->ops->type == OMAP_MBOX_TYPE1)
> @@ -298,13 +282,25 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
>  	}
>  	mbox->rxq = mq;
>  
> +	mbox->tx_tasklet->t =  kzalloc(sizeof(struct tasklet_struct),
> +					GFP_KERNEL);
> +	if (!mbox->tx_tasklet->t) {
> +		ret = -ENOMEM;
> +		goto fail_alloc_tasklet;
> +	}
> +	spin_lock_init(&mbox->tx_tasklet->lock);
> +	tasklet_init(mbox->tx_tasklet->t, __mbox_msg_send,
> +				(unsigned long)mbox->tx_tasklet);
> +
>  	return 0;
>  
> - fail_alloc_rxq:
> +fail_alloc_tasklet:
> +	mbox_queue_free(mbox->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 (unlikely(mbox->ops->shutdown))
>  		mbox->ops->shutdown(mbox);
>  
> -- 
> 1.5.3.2
> --
> 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	[flat|nested] 21+ messages in thread

* RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-07  8:49 ` Hiroshi DOYU
@ 2009-09-08 17:43   ` C.A, Subramaniam
  2009-09-09  9:02     ` Hiroshi DOYU
  0 siblings, 1 reply; 21+ messages in thread
From: C.A, Subramaniam @ 2009-09-08 17:43 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-omap@vger.kernel.org, tony@atomide.com,
	rmk@arm.linux.org.uk, Kanigeri, Hari, Gupta, Ramesh

Hi Hiroshi, 

> -----Original Message-----
> From: Hiroshi DOYU [mailto:Hiroshi.DOYU@nokia.com] 
> Sent: Monday, September 07, 2009 2:20 PM
> To: C.A, Subramaniam
> Cc: linux-omap@vger.kernel.org; tony@atomide.com; 
> rmk@arm.linux.org.uk; Kanigeri, Hari; Gupta, Ramesh
> Subject: Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> 
> From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
> Subject: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> Date: Fri, 4 Sep 2009 13:48:45 +0200
> 
> > From e759173e77f73fabce5177b4f685df20b16c6922 Mon Sep 17 
> 00:00:00 2001
> > From: C A Subramaniam <subramaniam.ca@ti.com>
> > Date: Thu, 3 Sep 2009 17:42:35 +0530
> > Subject: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet
> >    implementation
> > 
> > This patch uses a tasklet implementation for sending 
> mailbox messages.
> > 
> > Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
> > Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
> > ---
> >  arch/arm/mach-omap2/mailbox.c             |   43 ++++++++++-----
> >  arch/arm/plat-omap/include/mach/mailbox.h |   16 +++++-
> >  arch/arm/plat-omap/mailbox.c              |   80 
> ++++++++++++++---------------
> >  3 files changed, 81 insertions(+), 58 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap2/mailbox.c 
> > b/arch/arm/mach-omap2/mailbox.c index 52a1670..45aea98 100644
> > --- a/arch/arm/mach-omap2/mailbox.c
> > +++ b/arch/arm/mach-omap2/mailbox.c
> > @@ -236,6 +237,17 @@ static struct omap_mbox_ops omap2_mbox_ops = {
> >  	.restore_ctx	= omap2_mbox_restore_ctx,
> >  };
> >  
> > +
> > +static struct omap_mbox_task omap_mbox_1_tasklet = {
> > +	.arg	= NULL,
> > +};
> > +
> > +static struct omap_mbox_task omap_mbox_2_tasklet = {
> > +	.arg	= NULL,
> > +};
> 
> As I described in the comment on [PATCH 8/10], I think that 
> it would be better to keep "mach-omap2/mailbox.c" simple and 
> to add some additional logic on "plat-omap/mailbox.c".
> 
> Would it be possbile to move this tasklet implementation to 
> "plat-omap/mailbox.c"?

The implementation of the tasklet itself is maintained in plat-omap/mailbox.c
Since, I wanted to maintain a separate tasklet for each mailbox
instance used to send messages from MPU, I had to associate the the tasklet
to the mailbox. Hence, the changes were done in mach-omap2/mailbox.c

Please give your comments on this approach.

> 
> > +
> > +
> > +
> >  /*
> >   * MAILBOX 0: ARM -> DSP,
> >   * MAILBOX 1: ARM <- DSP.
> > @@ -272,6 +284,7 @@ struct omap_mbox mbox_1_info = {
> >  	.name	= "mailbox-1",
> >  	.ops	= &omap2_mbox_ops,
> >  	.priv	= &omap2_mbox_1_priv,
> > +	.tx_tasklet = &omap_mbox_1_tasklet,
> >  };
> >  EXPORT_SYMBOL(mbox_1_info);
> >  #else
> > @@ -305,8 +318,10 @@ struct omap_mbox mbox_2_info = {
> >  	.name	= "mailbox-2",
> >  	.ops	= &omap2_mbox_ops,
> >  	.priv	= &omap2_mbox_2_priv,
> > +	.tx_tasklet = &omap_mbox_2_tasklet,
> >  };
> >  EXPORT_SYMBOL(mbox_2_info);
> > +
> >  #endif
> >  
> >  
> > diff --git a/arch/arm/plat-omap/include/mach/mailbox.h 
> > b/arch/arm/plat-omap/include/mach/mailbox.h
> > index bf06953..5271345 100644
> > --- a/arch/arm/plat-omap/include/mach/mailbox.h
> > +++ b/arch/arm/plat-omap/include/mach/mailbox.h
> > @@ -28,8 +28,10 @@ struct omap_mbox_ops {
> >  	int		(*fifo_empty)(struct omap_mbox *mbox);
> >  	int		(*fifo_full)(struct omap_mbox *mbox);
> >  	/* irq */
> > -	void		(*enable_irq)(struct omap_mbox *mbox, 
> omap_mbox_irq_t irq);
> > -	void		(*disable_irq)(struct omap_mbox *mbox, 
> omap_mbox_irq_t irq);
> > +	void		(*enable_irq)(struct omap_mbox *mbox,
> > +						omap_mbox_irq_t irq);
> > +	void		(*disable_irq)(struct omap_mbox *mbox,
> > +						omap_mbox_irq_t irq);
> >  	void		(*ack_irq)(struct omap_mbox *mbox, 
> omap_mbox_irq_t irq);
> >  	int		(*is_irq)(struct omap_mbox *mbox, 
> omap_mbox_irq_t irq);
> >  	/* ctx */
> > @@ -45,12 +47,22 @@ struct omap_mbox_queue {
> >  	struct omap_mbox	*mbox;
> >  };
> >  
> > +struct omap_mbox_task{
> > +	spinlock_t		lock;
> > +	struct tasklet_struct	*t;
> > +	mbox_msg_t		msg;
> > +	void			*arg;
> > +};
> > +
> > +
> >  struct omap_mbox {
> >  	char			*name;
> >  	unsigned int		irq;
> >  
> >  	struct omap_mbox_queue	*txq, *rxq;
> >  
> > +	struct omap_mbox_task	*tx_tasklet;
> > +
> >  	struct omap_mbox_ops	*ops;
> >  
> >  	mbox_msg_t		seq_snd, seq_rcv;
> > diff --git a/arch/arm/plat-omap/mailbox.c 
> > b/arch/arm/plat-omap/mailbox.c index 84cf6af..b5e53d4 100644
> > --- a/arch/arm/plat-omap/mailbox.c
> > +++ b/arch/arm/plat-omap/mailbox.c
> > @@ -63,60 +63,49 @@ static inline int is_mbox_irq(struct omap_mbox 
> > *mbox, omap_mbox_irq_t irq)
> >  /*
> >   * message sender
> >   */
> > -static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
> > +static void __mbox_msg_send(unsigned long tx)
> >  {
> > +	struct omap_mbox_task *tx_data  =  (struct omap_mbox_task *)tx;
> > +	struct omap_mbox *mbox = (struct omap_mbox *)tx_data->arg;
> > +	mbox_msg_t msg = tx_data->msg;
> >  	int ret = 0, i = 1000;
> >  
> >  	while (mbox_fifo_full(mbox)) {
> > -		if (mbox->ops->type == OMAP_MBOX_TYPE2)
> > -			return -1;
> > -		if (--i == 0)
> > -			return -1;
> > +		if (mbox->ops->type == OMAP_MBOX_TYPE2) {
> > +			printk(KERN_ERR "Invalid mailbox type\n");
> > +			return ;
> > +		}
> > +		if (--i == 0) {
> > +			printk(KERN_ERR "Time out writing to 
> mailbox\n");
> > +			return ;
> > +		}
> >  		udelay(1);
> >  	}
> >  	mbox_fifo_write(mbox, msg);
> > -	return ret;
> > -}
> > -
> > -struct omap_msg_tx_data {
> > -	mbox_msg_t	msg;
> > -	void		*arg;
> > -};
> > +	tx_data->arg = NULL;
> > +	spin_unlock(&(mbox->tx_tasklet->lock));
> >  
> > -static void omap_msg_tx_end_io(struct request *rq, int error) -{
> > -	kfree(rq->special);
> > -	__blk_put_request(rq->q, rq);
> > +	return;
> >  }
> >  
> > +
> >  int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)  {
> > -	struct omap_msg_tx_data *tx_data;
> > -	struct request *rq;
> > -	struct request_queue *q = mbox->txq->queue;
> > +	struct omap_mbox_task *tx_task = mbox->tx_tasklet;
> >  
> > -	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
> > -	if (unlikely(!tx_data))
> > -		return -ENOMEM;
> > -
> > -	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
> > -	if (unlikely(!rq)) {
> > -		kfree(tx_data);
> > -		return -ENOMEM;
> > -	}
> > +	spin_lock(&(mbox->tx_tasklet->lock));
> > +	tx_task->arg = (void *)mbox;
> > +	tx_task->msg = msg;
> >  
> > -	tx_data->msg = msg;
> > -	rq->end_io = omap_msg_tx_end_io;
> > -	blk_insert_request(q, rq, 0, tx_data);
> > +	tasklet_schedule(tx_task->t);
> >  
> > -	schedule_work(&mbox->txq->work);
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(omap_mbox_msg_send);
> >  
> >  static void mbox_tx_work(struct work_struct *work)  {
> > -	int ret;
> > +	int ret = 0;
> >  	struct request *rq;
> >  	struct omap_mbox_queue *mq = container_of(work,
> >  				struct omap_mbox_queue, work);
> > @@ -124,8 +113,6 @@ static void mbox_tx_work(struct 
> work_struct *work)
> >  	struct request_queue *q = mbox->txq->queue;
> >  
> >  	while (1) {
> > -		struct omap_msg_tx_data *tx_data;
> > -
> >  		spin_lock(q->queue_lock);
> >  		rq = blk_fetch_request(q);
> >  		spin_unlock(q->queue_lock);
> > @@ -133,9 +120,6 @@ static void mbox_tx_work(struct 
> work_struct *work)
> >  		if (!rq)
> >  			break;
> >  
> > -		tx_data = rq->special;
> > -
> > -		ret = __mbox_msg_send(mbox, tx_data->msg);
> >  		if (ret) {
> >  			omap_mbox_enable_irq(mbox, IRQ_TX);
> >  			spin_lock(q->queue_lock);
> > @@ -206,7 +190,7 @@ static void __mbox_rx_interrupt(struct 
> omap_mbox *mbox)
> >  			goto nomem;
> >  
> >  		msg = mbox_fifo_read(mbox);
> > -
> > +		rq->special = (void *)msg;
> >  
> >  		blk_insert_request(q, rq, 0, (void *)msg);
> >  		if (mbox->ops->type == OMAP_MBOX_TYPE1) @@ 
> -298,13 +282,25 @@ 
> > static int omap_mbox_startup(struct omap_mbox *mbox)
> >  	}
> >  	mbox->rxq = mq;
> >  
> > +	mbox->tx_tasklet->t =  kzalloc(sizeof(struct tasklet_struct),
> > +					GFP_KERNEL);
> > +	if (!mbox->tx_tasklet->t) {
> > +		ret = -ENOMEM;
> > +		goto fail_alloc_tasklet;
> > +	}
> > +	spin_lock_init(&mbox->tx_tasklet->lock);
> > +	tasklet_init(mbox->tx_tasklet->t, __mbox_msg_send,
> > +				(unsigned long)mbox->tx_tasklet);
> > +
> >  	return 0;
> >  
> > - fail_alloc_rxq:
> > +fail_alloc_tasklet:
> > +	mbox_queue_free(mbox->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 (unlikely(mbox->ops->shutdown))
> >  		mbox->ops->shutdown(mbox);
> >  
> > --
> > 1.5.3.2
> > --
> > 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	[flat|nested] 21+ messages in thread

* Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-08 17:43   ` C.A, Subramaniam
@ 2009-09-09  9:02     ` Hiroshi DOYU
  2009-09-09  9:14       ` C.A, Subramaniam
  2009-09-10 11:46       ` C.A, Subramaniam
  0 siblings, 2 replies; 21+ messages in thread
From: Hiroshi DOYU @ 2009-09-09  9:02 UTC (permalink / raw)
  To: subramaniam.ca; +Cc: linux-omap, tony, rmk, h-kanigeri2, grgupta

Hi Subbu,

From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
Date: Tue, 8 Sep 2009 19:43:48 +0200

[...]

> > As I described in the comment on [PATCH 8/10], I think that 
> > it would be better to keep "mach-omap2/mailbox.c" simple and 
> > to add some additional logic on "plat-omap/mailbox.c".
> > 
> > Would it be possbile to move this tasklet implementation to 
> > "plat-omap/mailbox.c"?
> 
> The implementation of the tasklet itself is maintained in plat-omap/mailbox.c
> Since, I wanted to maintain a separate tasklet for each mailbox
> instance used to send messages from MPU, I had to associate the the tasklet
> to the mailbox. Hence, the changes were done in mach-omap2/mailbox.c
> 
> Please give your comments on this approach.

Wouldn't just converting work_queue to tasklet work like below?

(I havne't tested this at all, though...)

diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index b7a6991..1f4e53e 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -52,6 +52,8 @@ struct omap_mbox {
 
 	struct omap_mbox_queue	*txq, *rxq;
 
+	struct tasklet_struct	tx_tasklet;
+
 	struct omap_mbox_ops	*ops;
 
 	mbox_msg_t		seq_snd, seq_rcv;
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 40424ed..37267ca 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -184,22 +184,17 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void* arg)
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);
 
-static void mbox_tx_work(struct work_struct *work)
+static void mbox_tx_tasklet(unsigned long data)
 {
 	int ret;
 	struct request *rq;
-	struct omap_mbox_queue *mq = container_of(work,
-				struct omap_mbox_queue, work);
-	struct omap_mbox *mbox = mq->queue->queuedata;
+ 	struct omap_mbox *mbox = (struct omap_mbox *)data;
 	struct request_queue *q = mbox->txq->queue;
 
 	while (1) {
 		struct omap_msg_tx_data *tx_data;
 
-		spin_lock(q->queue_lock);
 		rq = blk_fetch_request(q);
-		spin_unlock(q->queue_lock);
-
 		if (!rq)
 			break;
 
@@ -208,15 +203,10 @@ static void mbox_tx_work(struct work_struct *work)
 		ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg);
 		if (ret) {
 			enable_mbox_irq(mbox, IRQ_TX);
-			spin_lock(q->queue_lock);
 			blk_requeue_request(q, rq);
-			spin_unlock(q->queue_lock);
 			return;
 		}
-
-		spin_lock(q->queue_lock);
 		__blk_end_request_all(rq, 0);
-		spin_unlock(q->queue_lock);
 	}
 }
 
@@ -266,7 +256,7 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
 {
 	disable_mbox_irq(mbox, IRQ_TX);
 	ack_mbox_irq(mbox, IRQ_TX);
-	schedule_work(&mbox->txq->work);
+	tasklet_schedule(&mbox->tx_tasklet);
 }
 
 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
@@ -434,7 +424,9 @@ static int omap_mbox_init(struct omap_mbox *mbox)
 		goto fail_request_irq;
 	}
 
-	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
+	tasklet_init(&mbox->tx_tasklet, mbox_tx_tasklet, (unsigned long)mbox);
+
+	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_txq;

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

* RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-09  9:02     ` Hiroshi DOYU
@ 2009-09-09  9:14       ` C.A, Subramaniam
  2009-09-10 11:46       ` C.A, Subramaniam
  1 sibling, 0 replies; 21+ messages in thread
From: C.A, Subramaniam @ 2009-09-09  9:14 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-omap@vger.kernel.org, tony@atomide.com,
	rmk@arm.linux.org.uk, Kanigeri, Hari, Gupta, Ramesh

 Hi Hiroshi,

> -----Original Message-----
> From: Hiroshi DOYU [mailto:Hiroshi.DOYU@nokia.com] 
> Sent: Wednesday, September 09, 2009 2:32 PM
> To: C.A, Subramaniam
> Cc: linux-omap@vger.kernel.org; tony@atomide.com; 
> rmk@arm.linux.org.uk; Kanigeri, Hari; Gupta, Ramesh
> Subject: Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> 
> Hi Subbu,
> 
> From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
> Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> Date: Tue, 8 Sep 2009 19:43:48 +0200
> 
> [...]
> 
> > > As I described in the comment on [PATCH 8/10], I think 
> that it would 
> > > be better to keep "mach-omap2/mailbox.c" simple and to add some 
> > > additional logic on "plat-omap/mailbox.c".
> > > 
> > > Would it be possbile to move this tasklet implementation to 
> > > "plat-omap/mailbox.c"?
> > 
> > The implementation of the tasklet itself is maintained in 
> > plat-omap/mailbox.c Since, I wanted to maintain a separate 
> tasklet for 
> > each mailbox instance used to send messages from MPU, I had to 
> > associate the the tasklet to the mailbox. Hence, the 
> changes were done 
> > in mach-omap2/mailbox.c
> > 
> > Please give your comments on this approach.
> 
> Wouldn't just converting work_queue to tasklet work like below?
> 
> (I havne't tested this at all, though...)
I will try that out and let you know. Also your approach seems better
as you are replacing the work queue implementaion as well.  
> 
> diff --git a/arch/arm/plat-omap/include/mach/mailbox.h 
> b/arch/arm/plat-omap/include/mach/mailbox.h
> index b7a6991..1f4e53e 100644
> --- a/arch/arm/plat-omap/include/mach/mailbox.h
> +++ b/arch/arm/plat-omap/include/mach/mailbox.h
> @@ -52,6 +52,8 @@ struct omap_mbox {
>  
>  	struct omap_mbox_queue	*txq, *rxq;
>  
> +	struct tasklet_struct	tx_tasklet;
> +
>  	struct omap_mbox_ops	*ops;
>  
>  	mbox_msg_t		seq_snd, seq_rcv;
> diff --git a/arch/arm/plat-omap/mailbox.c 
> b/arch/arm/plat-omap/mailbox.c index 40424ed..37267ca 100644
> --- a/arch/arm/plat-omap/mailbox.c
> +++ b/arch/arm/plat-omap/mailbox.c
> @@ -184,22 +184,17 @@ int omap_mbox_msg_send(struct omap_mbox 
> *mbox, mbox_msg_t msg, void* arg)  }  
> EXPORT_SYMBOL(omap_mbox_msg_send);
>  
> -static void mbox_tx_work(struct work_struct *work)
> +static void mbox_tx_tasklet(unsigned long data)
>  {
>  	int ret;
>  	struct request *rq;
> -	struct omap_mbox_queue *mq = container_of(work,
> -				struct omap_mbox_queue, work);
> -	struct omap_mbox *mbox = mq->queue->queuedata;
> + 	struct omap_mbox *mbox = (struct omap_mbox *)data;
>  	struct request_queue *q = mbox->txq->queue;
>  
>  	while (1) {
>  		struct omap_msg_tx_data *tx_data;
>  
> -		spin_lock(q->queue_lock);
>  		rq = blk_fetch_request(q);
> -		spin_unlock(q->queue_lock);
> -
>  		if (!rq)
>  			break;
>  
> @@ -208,15 +203,10 @@ static void mbox_tx_work(struct 
> work_struct *work)
>  		ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg);
>  		if (ret) {
>  			enable_mbox_irq(mbox, IRQ_TX);
> -			spin_lock(q->queue_lock);
>  			blk_requeue_request(q, rq);
> -			spin_unlock(q->queue_lock);
>  			return;
>  		}
> -
> -		spin_lock(q->queue_lock);
>  		__blk_end_request_all(rq, 0);
> -		spin_unlock(q->queue_lock);
>  	}
>  }
>  
> @@ -266,7 +256,7 @@ static void __mbox_tx_interrupt(struct 
> omap_mbox *mbox)  {
>  	disable_mbox_irq(mbox, IRQ_TX);
>  	ack_mbox_irq(mbox, IRQ_TX);
> -	schedule_work(&mbox->txq->work);
> +	tasklet_schedule(&mbox->tx_tasklet);
>  }
>  
>  static void __mbox_rx_interrupt(struct omap_mbox *mbox) @@ 
> -434,7 +424,9 @@ static int omap_mbox_init(struct omap_mbox *mbox)
>  		goto fail_request_irq;
>  	}
>  
> -	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> +	tasklet_init(&mbox->tx_tasklet, mbox_tx_tasklet, 
> (unsigned long)mbox);
> +
> +	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL);
>  	if (!mq) {
>  		ret = -ENOMEM;
>  		goto fail_alloc_txq;
> 
> 

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

* RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-09  9:02     ` Hiroshi DOYU
  2009-09-09  9:14       ` C.A, Subramaniam
@ 2009-09-10 11:46       ` C.A, Subramaniam
  2009-09-10 12:28         ` Hiroshi DOYU
  1 sibling, 1 reply; 21+ messages in thread
From: C.A, Subramaniam @ 2009-09-10 11:46 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-omap@vger.kernel.org, tony@atomide.com,
	rmk@arm.linux.org.uk, Kanigeri, Hari, Gupta, Ramesh

 
Hi Hiroshi,

> -----Original Message-----
> From: Hiroshi DOYU [mailto:Hiroshi.DOYU@nokia.com] 
> Sent: Wednesday, September 09, 2009 2:32 PM
> To: C.A, Subramaniam
> Cc: linux-omap@vger.kernel.org; tony@atomide.com; 
> rmk@arm.linux.org.uk; Kanigeri, Hari; Gupta, Ramesh
> Subject: Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> 
> Hi Subbu,
> 
> From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
> Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> Date: Tue, 8 Sep 2009 19:43:48 +0200
> 
> [...]
> 
> > > As I described in the comment on [PATCH 8/10], I think 
> that it would 
> > > be better to keep "mach-omap2/mailbox.c" simple and to add some 
> > > additional logic on "plat-omap/mailbox.c".
> > > 
> > > Would it be possbile to move this tasklet implementation to 
> > > "plat-omap/mailbox.c"?
> > 
> > The implementation of the tasklet itself is maintained in 
> > plat-omap/mailbox.c Since, I wanted to maintain a separate 
> tasklet for 
> > each mailbox instance used to send messages from MPU, I had to 
> > associate the the tasklet to the mailbox. Hence, the 
> changes were done 
> > in mach-omap2/mailbox.c
> > 
> > Please give your comments on this approach.
> 
> Wouldn't just converting work_queue to tasklet work like below?
> 
> (I havne't tested this at all, though...)
> 
> diff --git a/arch/arm/plat-omap/include/mach/mailbox.h 
> b/arch/arm/plat-omap/include/mach/mailbox.h
> index b7a6991..1f4e53e 100644
> --- a/arch/arm/plat-omap/include/mach/mailbox.h
> +++ b/arch/arm/plat-omap/include/mach/mailbox.h
> @@ -52,6 +52,8 @@ struct omap_mbox {
>  
>  	struct omap_mbox_queue	*txq, *rxq;
>  
> +	struct tasklet_struct	tx_tasklet;
> +
>  	struct omap_mbox_ops	*ops;
>  
>  	mbox_msg_t		seq_snd, seq_rcv;

Moved the tasklet structure to the omap_mbox_queue as follows:

@@ -40,7 +43,8 @@ struct omap_mbox_ops {
 struct omap_mbox_queue {
 	spinlock_t		lock;
 	struct request_queue	*queue;
-	struct work_struct	work;
+	struct work_struct	rx_work;
+	struct tasklet_struct	tx_tasklet;
 	int	(*callback)(void *);
 	struct omap_mbox	*mbox;
 };

Also chagned the omap_mbox_msg_send(). Removed the struct omap_msg_tx_data.

 
 int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 {
-	struct omap_msg_tx_data *tx_data;
+
 	struct request *rq;
 	struct request_queue *q = mbox->txq->queue;
 
-	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
-	if (unlikely(!tx_data))
-		return -ENOMEM;
-
 	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
-	if (unlikely(!rq)) {
-		kfree(tx_data);
+	if (unlikely(!rq))
 		return -ENOMEM;
-	}
 
-	tx_data->msg = msg;
-	rq->end_io = omap_msg_tx_end_io;
-	blk_insert_request(q, rq, 0, tx_data);
+	blk_insert_request(q, rq, 0, (void *) msg);
+	tasklet_schedule(&mbox->txq->tx_tasklet);
 
-	schedule_work(&mbox->txq->work);
 	return 0;
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);

> diff --git a/arch/arm/plat-omap/mailbox.c 
> b/arch/arm/plat-omap/mailbox.c index 40424ed..37267ca 100644
> --- a/arch/arm/plat-omap/mailbox.c
> +++ b/arch/arm/plat-omap/mailbox.c
> @@ -184,22 +184,17 @@ int omap_mbox_msg_send(struct omap_mbox 
> *mbox, mbox_msg_t msg, void* arg)  }  
> EXPORT_SYMBOL(omap_mbox_msg_send);
>  
> -static void mbox_tx_work(struct work_struct *work)
> +static void mbox_tx_tasklet(unsigned long data)
>  {
>  	int ret;
>  	struct request *rq;
> -	struct omap_mbox_queue *mq = container_of(work,
> -				struct omap_mbox_queue, work);
> -	struct omap_mbox *mbox = mq->queue->queuedata;
> + 	struct omap_mbox *mbox = (struct omap_mbox *)data;
>  	struct request_queue *q = mbox->txq->queue;
>  
>  	while (1) {
>  		struct omap_msg_tx_data *tx_data;
>  
> -		spin_lock(q->queue_lock);
>  		rq = blk_fetch_request(q);
> -		spin_unlock(q->queue_lock);
> -
>  		if (!rq)
>  			break;
>  
> @@ -208,15 +203,10 @@ static void mbox_tx_work(struct 
> work_struct *work)
>  		ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg);
>  		if (ret) {
>  			enable_mbox_irq(mbox, IRQ_TX);
> -			spin_lock(q->queue_lock);
>  			blk_requeue_request(q, rq);
> -			spin_unlock(q->queue_lock);
>  			return;
>  		}
> -
> -		spin_lock(q->queue_lock);
>  		__blk_end_request_all(rq, 0);
> -		spin_unlock(q->queue_lock);
>  	}
>  }
>  

Changed the mbox_tx_tasklet as follows:

-static void mbox_tx_work(struct work_struct *work)
+static void mbox_tx_tasklet(unsigned long tx_data)
 {
 	int ret;
 	struct request *rq;
-	struct omap_mbox_queue *mq = container_of(work,
-				struct omap_mbox_queue, work);
-	struct omap_mbox *mbox = mq->queue->queuedata;
+	struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
 	struct request_queue *q = mbox->txq->queue;
 
 	while (1) {
-		struct omap_msg_tx_data *tx_data;
 
-		spin_lock(q->queue_lock);
 		rq = blk_fetch_request(q);
-		spin_unlock(q->queue_lock);
 
 		if (!rq)
 			break;
 
-		tx_data = rq->special;
-
-		ret = __mbox_msg_send(mbox, tx_data->msg);
+		ret = __mbox_msg_send(mbox, (mbox_msg_t)rq->special);
 		if (ret) {
 			omap_mbox_enable_irq(mbox, IRQ_TX);
-			spin_lock(q->queue_lock);
 			blk_requeue_request(q, rq);
-			spin_unlock(q->queue_lock);
 			return;
 		}
-
-		spin_lock(q->queue_lock);
-		__blk_end_request_all(rq, 0);
-		spin_unlock(q->queue_lock);
+		/* FIXME: We get a WARN_ON() if __blk_end_request_all()
+		* is used. Not sure if we can remove the queue locks
+		* for blk_requeue_request() and blk_fetch_request()
+		* calls as well.*/
+		blk_end_request_all(rq, 0);
 	}
 }

While testing I got a WARN_ON() using the __blk_end_request_all(). 
Tried using the blk_end_request_all() instead, and that worked fine. 
Is it safe to remove the spin lock protection for all the calls 
inside the tasklet function as you had suggested?
Please comment.

> @@ -266,7 +256,7 @@ static void __mbox_tx_interrupt(struct 
> omap_mbox *mbox)  {
>  	disable_mbox_irq(mbox, IRQ_TX);
>  	ack_mbox_irq(mbox, IRQ_TX);
> -	schedule_work(&mbox->txq->work);
> +	tasklet_schedule(&mbox->tx_tasklet);
>  }
>  
>  static void __mbox_rx_interrupt(struct omap_mbox *mbox) @@ 
> -434,7 +424,9 @@ static int omap_mbox_init(struct omap_mbox *mbox)
>  		goto fail_request_irq;
>  	}
>

Changes in the names used for work queue (rx_work) and tasklet as tx_tasklet.

@@ -157,7 +132,7 @@ static void mbox_tx_work(struct work_struct *work)
 static void mbox_rx_work(struct work_struct *work)
 {
 	struct omap_mbox_queue *mq =
-			container_of(work, struct omap_mbox_queue, work);
+			container_of(work, struct omap_mbox_queue, rx_work);
 	struct omap_mbox *mbox = mq->queue->queuedata;
 	struct request_queue *q = mbox->rxq->queue;
 	struct request *rq;
@@ -192,7 +167,7 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
 {
 	omap_mbox_disable_irq(mbox, IRQ_TX);
 	ack_mbox_irq(mbox, IRQ_TX);
-	schedule_work(&mbox->txq->work);
+	tasklet_schedule(&mbox->txq->tx_tasklet);
 }
 
 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
@@ -217,7 +192,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 	/* no more messages in the fifo. clear IRQ source. */
 	ack_mbox_irq(mbox, IRQ_RX);
 nomem:
-	schedule_work(&mbox->rxq->work);
+	schedule_work(&mbox->rxq->rx_work);
 }

  
> -	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> +	tasklet_init(&mbox->tx_tasklet, mbox_tx_tasklet, 
> (unsigned long)mbox);
> +
> +	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL);
>  	if (!mq) {
>  		ret = -ENOMEM;
>  		goto fail_alloc_txq;
> 
> 

Changed the signature of the mbox_queue_alloc function. 
The work queue / tasklet initialization is done in the 
omap_mbox_startup() function.

static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
-					request_fn_proc *proc,
-					void (*work) (struct work_struct *))
+					request_fn_proc *proc)
 {
 	struct request_queue *q;
 	struct omap_mbox_queue *mq;
@@ -252,8 +226,6 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 	q->queuedata = mbox;
 	mq->queue = q;
 
-	INIT_WORK(&mq->work, work);
-
 	return mq;
 error:
 	kfree(mq);
@@ -292,18 +264,22 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 		goto fail_request_irq;
 	}
 
-	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
+	mq = mbox_queue_alloc(mbox, mbox_txq_fn);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_txq;
 	}
+
+	tasklet_init(&mq->tx_tasklet, mbox_tx_tasklet, (unsigned long)mbox);
 	mbox->txq = mq;
 
-	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work);
+	mq = mbox_queue_alloc(mbox, mbox_rxq_fn);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_rxq;
 	}
+
+	INIT_WORK(&mq->rx_work, mbox_rx_work);
 	mbox->rxq = mq;
 
 	return 0;
--

Please give your comments on the changes.

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

* Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-10 11:46       ` C.A, Subramaniam
@ 2009-09-10 12:28         ` Hiroshi DOYU
  2009-09-14 11:35           ` C.A, Subramaniam
  0 siblings, 1 reply; 21+ messages in thread
From: Hiroshi DOYU @ 2009-09-10 12:28 UTC (permalink / raw)
  To: subramaniam.ca; +Cc: linux-omap, tony, rmk, h-kanigeri2, grgupta

From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
Date: Thu, 10 Sep 2009 13:46:53 +0200

> 
>  
> Hi Hiroshi,
> 
> > -----Original Message-----
> > From: Hiroshi DOYU [mailto:Hiroshi.DOYU@nokia.com] 
> > Sent: Wednesday, September 09, 2009 2:32 PM
> > To: C.A, Subramaniam
> > Cc: linux-omap@vger.kernel.org; tony@atomide.com; 
> > rmk@arm.linux.org.uk; Kanigeri, Hari; Gupta, Ramesh
> > Subject: Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> > Patch to support tasklet implementation
> > 
> > Hi Subbu,
> > 
> > From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
> > Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> > Patch to support tasklet implementation
> > Date: Tue, 8 Sep 2009 19:43:48 +0200
> > 
> > [...]
> > 
> > > > As I described in the comment on [PATCH 8/10], I think 
> > that it would 
> > > > be better to keep "mach-omap2/mailbox.c" simple and to add some 
> > > > additional logic on "plat-omap/mailbox.c".
> > > > 
> > > > Would it be possbile to move this tasklet implementation to 
> > > > "plat-omap/mailbox.c"?
> > > 
> > > The implementation of the tasklet itself is maintained in 
> > > plat-omap/mailbox.c Since, I wanted to maintain a separate 
> > tasklet for 
> > > each mailbox instance used to send messages from MPU, I had to 
> > > associate the the tasklet to the mailbox. Hence, the 
> > changes were done 
> > > in mach-omap2/mailbox.c
> > > 
> > > Please give your comments on this approach.
> > 
> > Wouldn't just converting work_queue to tasklet work like below?
> > 
> > (I havne't tested this at all, though...)
> > 
> > diff --git a/arch/arm/plat-omap/include/mach/mailbox.h 
> > b/arch/arm/plat-omap/include/mach/mailbox.h
> > index b7a6991..1f4e53e 100644
> > --- a/arch/arm/plat-omap/include/mach/mailbox.h
> > +++ b/arch/arm/plat-omap/include/mach/mailbox.h
> > @@ -52,6 +52,8 @@ struct omap_mbox {
> >  
> >  	struct omap_mbox_queue	*txq, *rxq;
> >  
> > +	struct tasklet_struct	tx_tasklet;
> > +
> >  	struct omap_mbox_ops	*ops;
> >  
> >  	mbox_msg_t		seq_snd, seq_rcv;
> 
> Moved the tasklet structure to the omap_mbox_queue as follows:

This is better.

> 
> @@ -40,7 +43,8 @@ struct omap_mbox_ops {
>  struct omap_mbox_queue {
>  	spinlock_t		lock;
>  	struct request_queue	*queue;
> -	struct work_struct	work;
> +	struct work_struct	rx_work;
> +	struct tasklet_struct	tx_tasklet;
>  	int	(*callback)(void *);
>  	struct omap_mbox	*mbox;
>  };


I think that "rx_/tx_" prefix may not be necessary if you add tasklet
feature in "omap_mbox_queue" as followed since "omap_mbox_queue" can
be considered as s/w queue which can evoke workqueue/tasklet
accordingly.


+	struct work_struct	work;
+	struct tasklet_struct	tasklet;
 	int	(*callback)(void *);
 	struct omap_mbox	*mbox;
 };


> 
> Also chagned the omap_mbox_msg_send(). Removed the struct omap_msg_tx_data.
> 
>  
>  int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
>  {
> -	struct omap_msg_tx_data *tx_data;
> +
>  	struct request *rq;
>  	struct request_queue *q = mbox->txq->queue;
>  
> -	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
> -	if (unlikely(!tx_data))
> -		return -ENOMEM;
> -
>  	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
> -	if (unlikely(!rq)) {
> -		kfree(tx_data);
> +	if (unlikely(!rq))
>  		return -ENOMEM;
> -	}
>  
> -	tx_data->msg = msg;
> -	rq->end_io = omap_msg_tx_end_io;
> -	blk_insert_request(q, rq, 0, tx_data);
> +	blk_insert_request(q, rq, 0, (void *) msg);
> +	tasklet_schedule(&mbox->txq->tx_tasklet);
>  
> -	schedule_work(&mbox->txq->work);
>  	return 0;
>  }
>  EXPORT_SYMBOL(omap_mbox_msg_send);
> 
> > diff --git a/arch/arm/plat-omap/mailbox.c 
> > b/arch/arm/plat-omap/mailbox.c index 40424ed..37267ca 100644
> > --- a/arch/arm/plat-omap/mailbox.c
> > +++ b/arch/arm/plat-omap/mailbox.c
> > @@ -184,22 +184,17 @@ int omap_mbox_msg_send(struct omap_mbox 
> > *mbox, mbox_msg_t msg, void* arg)  }  
> > EXPORT_SYMBOL(omap_mbox_msg_send);
> >  
> > -static void mbox_tx_work(struct work_struct *work)
> > +static void mbox_tx_tasklet(unsigned long data)
> >  {
> >  	int ret;
> >  	struct request *rq;
> > -	struct omap_mbox_queue *mq = container_of(work,
> > -				struct omap_mbox_queue, work);
> > -	struct omap_mbox *mbox = mq->queue->queuedata;
> > + 	struct omap_mbox *mbox = (struct omap_mbox *)data;
> >  	struct request_queue *q = mbox->txq->queue;
> >  
> >  	while (1) {
> >  		struct omap_msg_tx_data *tx_data;
> >  
> > -		spin_lock(q->queue_lock);
> >  		rq = blk_fetch_request(q);
> > -		spin_unlock(q->queue_lock);
> > -
> >  		if (!rq)
> >  			break;
> >  
> > @@ -208,15 +203,10 @@ static void mbox_tx_work(struct 
> > work_struct *work)
> >  		ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg);
> >  		if (ret) {
> >  			enable_mbox_irq(mbox, IRQ_TX);
> > -			spin_lock(q->queue_lock);
> >  			blk_requeue_request(q, rq);
> > -			spin_unlock(q->queue_lock);
> >  			return;
> >  		}
> > -
> > -		spin_lock(q->queue_lock);
> >  		__blk_end_request_all(rq, 0);
> > -		spin_unlock(q->queue_lock);
> >  	}
> >  }
> >  
> 
> Changed the mbox_tx_tasklet as follows:
> 
> -static void mbox_tx_work(struct work_struct *work)
> +static void mbox_tx_tasklet(unsigned long tx_data)
>  {
>  	int ret;
>  	struct request *rq;
> -	struct omap_mbox_queue *mq = container_of(work,
> -				struct omap_mbox_queue, work);
> -	struct omap_mbox *mbox = mq->queue->queuedata;
> +	struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
>  	struct request_queue *q = mbox->txq->queue;
>  
>  	while (1) {
> -		struct omap_msg_tx_data *tx_data;
>  
> -		spin_lock(q->queue_lock);
>  		rq = blk_fetch_request(q);
> -		spin_unlock(q->queue_lock);
>  
>  		if (!rq)
>  			break;
>  
> -		tx_data = rq->special;
> -
> -		ret = __mbox_msg_send(mbox, tx_data->msg);
> +		ret = __mbox_msg_send(mbox, (mbox_msg_t)rq->special);
>  		if (ret) {
>  			omap_mbox_enable_irq(mbox, IRQ_TX);
> -			spin_lock(q->queue_lock);
>  			blk_requeue_request(q, rq);
> -			spin_unlock(q->queue_lock);
>  			return;
>  		}
> -
> -		spin_lock(q->queue_lock);
> -		__blk_end_request_all(rq, 0);
> -		spin_unlock(q->queue_lock);
> +		/* FIXME: We get a WARN_ON() if __blk_end_request_all()
> +		* is used. Not sure if we can remove the queue locks
> +		* for blk_requeue_request() and blk_fetch_request()
> +		* calls as well.*/
> +		blk_end_request_all(rq, 0);
>  	}
>  }
> 
> While testing I got a WARN_ON() using the __blk_end_request_all(). 
> Tried using the blk_end_request_all() instead, and that worked fine. 
> Is it safe to remove the spin lock protection for all the calls 
> inside the tasklet function as you had suggested?
> Please comment.

I think that it's safe since it's being executed in tasklet context,
no preemption.

Which WARN_ON() did you get?

> 
> > @@ -266,7 +256,7 @@ static void __mbox_tx_interrupt(struct 
> > omap_mbox *mbox)  {
> >  	disable_mbox_irq(mbox, IRQ_TX);
> >  	ack_mbox_irq(mbox, IRQ_TX);
> > -	schedule_work(&mbox->txq->work);
> > +	tasklet_schedule(&mbox->tx_tasklet);
> >  }
> >  
> >  static void __mbox_rx_interrupt(struct omap_mbox *mbox) @@ 
> > -434,7 +424,9 @@ static int omap_mbox_init(struct omap_mbox *mbox)
> >  		goto fail_request_irq;
> >  	}
> >
> 
> Changes in the names used for work queue (rx_work) and tasklet as
> tx_tasklet.

As I explained above, the prefix 'tx_/rx_' isn't necessary.

> 
> @@ -157,7 +132,7 @@ static void mbox_tx_work(struct work_struct *work)
>  static void mbox_rx_work(struct work_struct *work)
>  {
>  	struct omap_mbox_queue *mq =
> -			container_of(work, struct omap_mbox_queue, work);
> +			container_of(work, struct omap_mbox_queue, rx_work);
>  	struct omap_mbox *mbox = mq->queue->queuedata;
>  	struct request_queue *q = mbox->rxq->queue;
>  	struct request *rq;
> @@ -192,7 +167,7 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
>  {
>  	omap_mbox_disable_irq(mbox, IRQ_TX);
>  	ack_mbox_irq(mbox, IRQ_TX);
> -	schedule_work(&mbox->txq->work);
> +	tasklet_schedule(&mbox->txq->tx_tasklet);
>  }
>  
>  static void __mbox_rx_interrupt(struct omap_mbox *mbox)
> @@ -217,7 +192,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
>  	/* no more messages in the fifo. clear IRQ source. */
>  	ack_mbox_irq(mbox, IRQ_RX);
>  nomem:
> -	schedule_work(&mbox->rxq->work);
> +	schedule_work(&mbox->rxq->rx_work);
>  }
> 
>   
> > -	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> > +	tasklet_init(&mbox->tx_tasklet, mbox_tx_tasklet, 
> > (unsigned long)mbox);
> > +
> > +	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL);
> >  	if (!mq) {
> >  		ret = -ENOMEM;
> >  		goto fail_alloc_txq;
> > 
> > 
> 
> Changed the signature of the mbox_queue_alloc function. 
> The work queue / tasklet initialization is done in the 
> omap_mbox_startup() function.

why?

>
> static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
> -					request_fn_proc *proc,
> -					void (*work) (struct work_struct *))
> +					request_fn_proc *proc)
>  {
>  	struct request_queue *q;
>  	struct omap_mbox_queue *mq;
> @@ -252,8 +226,6 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
>  	q->queuedata = mbox;
>  	mq->queue = q;
>  
> -	INIT_WORK(&mq->work, work);
> -
>  	return mq;
>  error:
>  	kfree(mq);
> @@ -292,18 +264,22 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
>  		goto fail_request_irq;
>  	}
>  
> -	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> +	mq = mbox_queue_alloc(mbox, mbox_txq_fn);
>  	if (!mq) {
>  		ret = -ENOMEM;
>  		goto fail_alloc_txq;
>  	}
> +
> +	tasklet_init(&mq->tx_tasklet, mbox_tx_tasklet, (unsigned long)mbox);
>  	mbox->txq = mq;
>  
> -	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work);
> +	mq = mbox_queue_alloc(mbox, mbox_rxq_fn);
>  	if (!mq) {
>  		ret = -ENOMEM;
>  		goto fail_alloc_rxq;
>  	}
> +
> +	INIT_WORK(&mq->rx_work, mbox_rx_work);
>  	mbox->rxq = mq;
>  
>  	return 0;
> --
> 
> Please give your comments on the changes.
> --
> 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	[flat|nested] 21+ messages in thread

* RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-10 12:28         ` Hiroshi DOYU
@ 2009-09-14 11:35           ` C.A, Subramaniam
  2009-09-14 12:43             ` Hiroshi DOYU
  0 siblings, 1 reply; 21+ messages in thread
From: C.A, Subramaniam @ 2009-09-14 11:35 UTC (permalink / raw)
  To: Hiroshi DOYU
  Cc: linux-omap@vger.kernel.org, tony@atomide.com,
	rmk@arm.linux.org.uk, Kanigeri, Hari, Gupta, Ramesh

Hi Hiroshi,
Sorry for the delayed response. 

> -----Original Message-----
> From: Hiroshi DOYU [mailto:Hiroshi.DOYU@Nokia.com] 
> Sent: Thursday, September 10, 2009 5:59 PM
> To: C.A, Subramaniam
> Cc: linux-omap@vger.kernel.org; tony@atomide.com; 
> rmk@arm.linux.org.uk; Kanigeri, Hari; Gupta, Ramesh
> Subject: Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> 
> From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
> Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver 
> Patch to support tasklet implementation
> Date: Thu, 10 Sep 2009 13:46:53 +0200
> 
> > 
> >  
> > Hi Hiroshi,
> > 
> > > -----Original Message-----
> > > From: Hiroshi DOYU [mailto:Hiroshi.DOYU@nokia.com]
> > > Sent: Wednesday, September 09, 2009 2:32 PM
> > > To: C.A, Subramaniam
> > > Cc: linux-omap@vger.kernel.org; tony@atomide.com; 
> > > rmk@arm.linux.org.uk; Kanigeri, Hari; Gupta, Ramesh
> > > Subject: Re: [PATCH 10/10] omap mailbox: OMAP4 
> Mailbox-driver Patch 
> > > to support tasklet implementation
> > > 
> > > Hi Subbu,
> > > 
> > > From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
> > > Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 
> Mailbox-driver Patch 
> > > to support tasklet implementation
> > > Date: Tue, 8 Sep 2009 19:43:48 +0200
> > > 
> > > [...]
> > > 
> > > > > As I described in the comment on [PATCH 8/10], I think
> > > that it would
> > > > > be better to keep "mach-omap2/mailbox.c" simple and 
> to add some 
> > > > > additional logic on "plat-omap/mailbox.c".
> > > > > 
> > > > > Would it be possbile to move this tasklet implementation to 
> > > > > "plat-omap/mailbox.c"?
> > > > 
> > > > The implementation of the tasklet itself is maintained in 
> > > > plat-omap/mailbox.c Since, I wanted to maintain a separate
> > > tasklet for
> > > > each mailbox instance used to send messages from MPU, I had to 
> > > > associate the the tasklet to the mailbox. Hence, the
> > > changes were done
> > > > in mach-omap2/mailbox.c
> > > > 
> > > > Please give your comments on this approach.
> > > 
> > > Wouldn't just converting work_queue to tasklet work like below?
> > > 
> > > (I havne't tested this at all, though...)
> > > 
> > > diff --git a/arch/arm/plat-omap/include/mach/mailbox.h
> > > b/arch/arm/plat-omap/include/mach/mailbox.h
> > > index b7a6991..1f4e53e 100644
> > > --- a/arch/arm/plat-omap/include/mach/mailbox.h
> > > +++ b/arch/arm/plat-omap/include/mach/mailbox.h
> > > @@ -52,6 +52,8 @@ struct omap_mbox {
> > >  
> > >  	struct omap_mbox_queue	*txq, *rxq;
> > >  
> > > +	struct tasklet_struct	tx_tasklet;
> > > +
> > >  	struct omap_mbox_ops	*ops;
> > >  
> > >  	mbox_msg_t		seq_snd, seq_rcv;
> > 
> > Moved the tasklet structure to the omap_mbox_queue as follows:
> 
> This is better.
> 
> > 
> > @@ -40,7 +43,8 @@ struct omap_mbox_ops {  struct omap_mbox_queue {
> >  	spinlock_t		lock;
> >  	struct request_queue	*queue;
> > -	struct work_struct	work;
> > +	struct work_struct	rx_work;
> > +	struct tasklet_struct	tx_tasklet;
> >  	int	(*callback)(void *);
> >  	struct omap_mbox	*mbox;
> >  };
> 
> 
> I think that "rx_/tx_" prefix may not be necessary if you add 
> tasklet feature in "omap_mbox_queue" as followed since 
> "omap_mbox_queue" can be considered as s/w queue which can 
> evoke workqueue/tasklet accordingly.
> 
> 
> +	struct work_struct	work;
> +	struct tasklet_struct	tasklet;
>  	int	(*callback)(void *);
>  	struct omap_mbox	*mbox;
>  };

This is fine. Will remove rx_ and tx_ prefix.
> 
> 
> > 
> > Also chagned the omap_mbox_msg_send(). Removed the struct 
> omap_msg_tx_data.
> > 
> >  
> >  int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)  {
> > -	struct omap_msg_tx_data *tx_data;
> > +
> >  	struct request *rq;
> >  	struct request_queue *q = mbox->txq->queue;
> >  
> > -	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
> > -	if (unlikely(!tx_data))
> > -		return -ENOMEM;
> > -
> >  	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
> > -	if (unlikely(!rq)) {
> > -		kfree(tx_data);
> > +	if (unlikely(!rq))
> >  		return -ENOMEM;
> > -	}
> >  
> > -	tx_data->msg = msg;
> > -	rq->end_io = omap_msg_tx_end_io;
> > -	blk_insert_request(q, rq, 0, tx_data);
> > +	blk_insert_request(q, rq, 0, (void *) msg);
> > +	tasklet_schedule(&mbox->txq->tx_tasklet);
> >  
> > -	schedule_work(&mbox->txq->work);
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(omap_mbox_msg_send);
> > 
> > > diff --git a/arch/arm/plat-omap/mailbox.c 
> > > b/arch/arm/plat-omap/mailbox.c index 40424ed..37267ca 100644
> > > --- a/arch/arm/plat-omap/mailbox.c
> > > +++ b/arch/arm/plat-omap/mailbox.c
> > > @@ -184,22 +184,17 @@ int omap_mbox_msg_send(struct 
> omap_mbox *mbox, 
> > > mbox_msg_t msg, void* arg)  } EXPORT_SYMBOL(omap_mbox_msg_send);
> > >  
> > > -static void mbox_tx_work(struct work_struct *work)
> > > +static void mbox_tx_tasklet(unsigned long data)
> > >  {
> > >  	int ret;
> > >  	struct request *rq;
> > > -	struct omap_mbox_queue *mq = container_of(work,
> > > -				struct omap_mbox_queue, work);
> > > -	struct omap_mbox *mbox = mq->queue->queuedata;
> > > + 	struct omap_mbox *mbox = (struct omap_mbox *)data;
> > >  	struct request_queue *q = mbox->txq->queue;
> > >  
> > >  	while (1) {
> > >  		struct omap_msg_tx_data *tx_data;
> > >  
> > > -		spin_lock(q->queue_lock);
> > >  		rq = blk_fetch_request(q);
> > > -		spin_unlock(q->queue_lock);
> > > -
> > >  		if (!rq)
> > >  			break;
> > >  
> > > @@ -208,15 +203,10 @@ static void mbox_tx_work(struct work_struct 
> > > *work)
> > >  		ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg);
> > >  		if (ret) {
> > >  			enable_mbox_irq(mbox, IRQ_TX);
> > > -			spin_lock(q->queue_lock);
> > >  			blk_requeue_request(q, rq);
> > > -			spin_unlock(q->queue_lock);
> > >  			return;
> > >  		}
> > > -
> > > -		spin_lock(q->queue_lock);
> > >  		__blk_end_request_all(rq, 0);
> > > -		spin_unlock(q->queue_lock);
> > >  	}
> > >  }
> > >  
> > 
> > Changed the mbox_tx_tasklet as follows:
> > 
> > -static void mbox_tx_work(struct work_struct *work)
> > +static void mbox_tx_tasklet(unsigned long tx_data)
> >  {
> >  	int ret;
> >  	struct request *rq;
> > -	struct omap_mbox_queue *mq = container_of(work,
> > -				struct omap_mbox_queue, work);
> > -	struct omap_mbox *mbox = mq->queue->queuedata;
> > +	struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
> >  	struct request_queue *q = mbox->txq->queue;
> >  
> >  	while (1) {
> > -		struct omap_msg_tx_data *tx_data;
> >  
> > -		spin_lock(q->queue_lock);
> >  		rq = blk_fetch_request(q);
> > -		spin_unlock(q->queue_lock);
> >  
> >  		if (!rq)
> >  			break;
> >  
> > -		tx_data = rq->special;
> > -
> > -		ret = __mbox_msg_send(mbox, tx_data->msg);
> > +		ret = __mbox_msg_send(mbox, (mbox_msg_t)rq->special);
> >  		if (ret) {
> >  			omap_mbox_enable_irq(mbox, IRQ_TX);
> > -			spin_lock(q->queue_lock);
> >  			blk_requeue_request(q, rq);
> > -			spin_unlock(q->queue_lock);
> >  			return;
> >  		}
> > -
> > -		spin_lock(q->queue_lock);
> > -		__blk_end_request_all(rq, 0);
> > -		spin_unlock(q->queue_lock);
> > +		/* FIXME: We get a WARN_ON() if __blk_end_request_all()
> > +		* is used. Not sure if we can remove the queue locks
> > +		* for blk_requeue_request() and blk_fetch_request()
> > +		* calls as well.*/
> > +		blk_end_request_all(rq, 0);
> >  	}
> >  }
> > 
> > While testing I got a WARN_ON() using the __blk_end_request_all(). 
> > Tried using the blk_end_request_all() instead, and that 
> worked fine. 
> > Is it safe to remove the spin lock protection for all the 
> calls inside 
> > the tasklet function as you had suggested?
> > Please comment.
> 
> I think that it's safe since it's being executed in tasklet 
> context, no preemption.
> 
> Which WARN_ON() did you get?
> 

WARNING: at include/linux/blkdev.h:522
WARN_ON_ONCE(!queue_is_locked(q));
The __blk_end_request_all() needs the queue to be locked before making the call.
However, the blk_end_request_all() call does not have this requirement.

> > 
> > > @@ -266,7 +256,7 @@ static void 
> __mbox_tx_interrupt(struct omap_mbox 
> > > *mbox)  {
> > >  	disable_mbox_irq(mbox, IRQ_TX);
> > >  	ack_mbox_irq(mbox, IRQ_TX);
> > > -	schedule_work(&mbox->txq->work);
> > > +	tasklet_schedule(&mbox->tx_tasklet);
> > >  }
> > >  
> > >  static void __mbox_rx_interrupt(struct omap_mbox *mbox) @@
> > > -434,7 +424,9 @@ static int omap_mbox_init(struct omap_mbox *mbox)
> > >  		goto fail_request_irq;
> > >  	}
> > >
> > 
> > Changes in the names used for work queue (rx_work) and tasklet as 
> > tx_tasklet.
> 
> As I explained above, the prefix 'tx_/rx_' isn't necessary.
> 
I will remove the tx_ rx_ as you had suggested.

> > 
> > @@ -157,7 +132,7 @@ static void mbox_tx_work(struct 
> work_struct *work)  
> > static void mbox_rx_work(struct work_struct *work)  {
> >  	struct omap_mbox_queue *mq =
> > -			container_of(work, struct 
> omap_mbox_queue, work);
> > +			container_of(work, struct 
> omap_mbox_queue, rx_work);
> >  	struct omap_mbox *mbox = mq->queue->queuedata;
> >  	struct request_queue *q = mbox->rxq->queue;
> >  	struct request *rq;
> > @@ -192,7 +167,7 @@ static void __mbox_tx_interrupt(struct 
> omap_mbox 
> > *mbox)  {
> >  	omap_mbox_disable_irq(mbox, IRQ_TX);
> >  	ack_mbox_irq(mbox, IRQ_TX);
> > -	schedule_work(&mbox->txq->work);
> > +	tasklet_schedule(&mbox->txq->tx_tasklet);
> >  }
> >  
> >  static void __mbox_rx_interrupt(struct omap_mbox *mbox) @@ -217,7 
> > +192,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
> >  	/* no more messages in the fifo. clear IRQ source. */
> >  	ack_mbox_irq(mbox, IRQ_RX);
> >  nomem:
> > -	schedule_work(&mbox->rxq->work);
> > +	schedule_work(&mbox->rxq->rx_work);
> >  }
> > 
> >   
> > > -	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> > > +	tasklet_init(&mbox->tx_tasklet, mbox_tx_tasklet,
> > > (unsigned long)mbox);
> > > +
> > > +	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL);
> > >  	if (!mq) {
> > >  		ret = -ENOMEM;
> > >  		goto fail_alloc_txq;
> > > 
> > > 
> > 
> > Changed the signature of the mbox_queue_alloc function. 
> > The work queue / tasklet initialization is done in the
> > omap_mbox_startup() function.
> 
> why?

The mbox_queue_alloc() currently, takes only the work queue function 
as an argument. With the tasklet introduced, I felt it is better to 
have work queue/ tasklet initializations,done outside the 
mbox_queue_alloc() function. 

Doing the tasklet initializtion in startup looks more like a work-around.
Another option would be to pass both the work_queue and tasklet functions 
as arguments to the mbox_queue_alloc() function.

Please comment.

> 
> >
> > static struct omap_mbox_queue *mbox_queue_alloc(struct 
> omap_mbox *mbox,
> > -					request_fn_proc *proc,
> > -					void (*work) (struct 
> work_struct *))
> > +					request_fn_proc *proc)
> >  {
> >  	struct request_queue *q;
> >  	struct omap_mbox_queue *mq;
> > @@ -252,8 +226,6 @@ static struct omap_mbox_queue 
> *mbox_queue_alloc(struct omap_mbox *mbox,
> >  	q->queuedata = mbox;
> >  	mq->queue = q;
> >  
> > -	INIT_WORK(&mq->work, work);
> > -
> >  	return mq;
> >  error:
> >  	kfree(mq);
> > @@ -292,18 +264,22 @@ static int omap_mbox_startup(struct 
> omap_mbox *mbox)
> >  		goto fail_request_irq;
> >  	}
> >  
> > -	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> > +	mq = mbox_queue_alloc(mbox, mbox_txq_fn);
> >  	if (!mq) {
> >  		ret = -ENOMEM;
> >  		goto fail_alloc_txq;
> >  	}
> > +
> > +	tasklet_init(&mq->tx_tasklet, mbox_tx_tasklet, 
> (unsigned long)mbox);
> >  	mbox->txq = mq;
> >  
> > -	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work);
> > +	mq = mbox_queue_alloc(mbox, mbox_rxq_fn);
> >  	if (!mq) {
> >  		ret = -ENOMEM;
> >  		goto fail_alloc_rxq;
> >  	}
> > +
> > +	INIT_WORK(&mq->rx_work, mbox_rx_work);
> >  	mbox->rxq = mq;
> >  
> >  	return 0;
> > --
> > 
> > Please give your comments on the changes.
> > --
> > 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	[flat|nested] 21+ messages in thread

* Re: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-09-14 11:35           ` C.A, Subramaniam
@ 2009-09-14 12:43             ` Hiroshi DOYU
  0 siblings, 0 replies; 21+ messages in thread
From: Hiroshi DOYU @ 2009-09-14 12:43 UTC (permalink / raw)
  To: subramaniam.ca; +Cc: linux-omap, tony, rmk, h-kanigeri2, grgupta

Hi Subbu,

From: "ext C.A, Subramaniam" <subramaniam.ca@ti.com>
Subject: RE: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
Date: Mon, 14 Sep 2009 13:35:23 +0200

[...]

> > > -
> > > -           spin_lock(q->queue_lock);
> > > -           __blk_end_request_all(rq, 0);
> > > -           spin_unlock(q->queue_lock);
> > > +           /* FIXME: We get a WARN_ON() if __blk_end_request_all()
> > > +           * is used. Not sure if we can remove the queue locks
> > > +           * for blk_requeue_request() and blk_fetch_request()
> > > +           * calls as well.*/
> > > +           blk_end_request_all(rq, 0);
> > >     }
> > >  }
> > >
> > > While testing I got a WARN_ON() using the __blk_end_request_all().
> > > Tried using the blk_end_request_all() instead, and that
> > worked fine.
> > > Is it safe to remove the spin lock protection for all the
> > calls inside
> > > the tasklet function as you had suggested?
> > > Please comment.
> >
> > I think that it's safe since it's being executed in tasklet
> > context, no preemption.
> >
> > Which WARN_ON() did you get?
> >
> 
> WARNING: at include/linux/blkdev.h:522
> WARN_ON_ONCE(!queue_is_locked(q));
> The __blk_end_request_all() needs the queue to be locked before making the call.
> However, the blk_end_request_all() call does not have this requirement.

Although it's safe without locking, __blk_end_request_all() wasn't
supposed to be used in tasklet context.

Let's use "blk_end_request_all()" until we'll come up with a better
idea while I think that request queue may be a little bit too heavy
for this porpose.

[...]
> > >  static void __mbox_rx_interrupt(struct omap_mbox *mbox) @@ -217,7
> > > +192,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
> > >     /* no more messages in the fifo. clear IRQ source. */
> > >     ack_mbox_irq(mbox, IRQ_RX);
> > >  nomem:
> > > -   schedule_work(&mbox->rxq->work);
> > > +   schedule_work(&mbox->rxq->rx_work);
> > >  }
> > >
> > >
> > > > - mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
> > > > + tasklet_init(&mbox->tx_tasklet, mbox_tx_tasklet,
> > > > (unsigned long)mbox);
> > > > +
> > > > + mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL);
> > > >   if (!mq) {
> > > >           ret = -ENOMEM;
> > > >           goto fail_alloc_txq;
> > > >
> > > >
> > >
> > > Changed the signature of the mbox_queue_alloc function.
> > > The work queue / tasklet initialization is done in the
> > > omap_mbox_startup() function.
> >
> > why?
> 
> The mbox_queue_alloc() currently, takes only the work queue function
> as an argument. With the tasklet introduced, I felt it is better to
> have work queue/ tasklet initializations,done outside the
> mbox_queue_alloc() function.
> 
> Doing the tasklet initializtion in startup looks more like a work-around.
> Another option would be to pass both the work_queue and tasklet functions
> as arguments to the mbox_queue_alloc() function.

I second passing tasklet func as argument for mbox_queue_alloc because
mbox_queue_alloc() was originally introduced to avoid repeating the
same initialization steps for rx and tx. For me, doing all
initialization per mbox queue in this function seems to be the way.



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

* [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
@ 2009-11-13 12:34 C.A, Subramaniam
  0 siblings, 0 replies; 21+ messages in thread
From: C.A, Subramaniam @ 2009-11-13 12:34 UTC (permalink / raw)
  To: Tony Lindgren, linux-omap@vger.kernel.org
  Cc: Gupta, Ramesh, Kanigeri, Hari, Hiroshi DOYU

>From 5fd7c2bfae11879edfcae7db073deb11bea1f584 Mon Sep 17 00:00:00 2001
From: C A Subramaniam <subramaniam.ca@ti.com>
Date: Fri, 13 Nov 2009 15:59:58 +0530
Subject: [PATCH 10/10] omap mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation

This patch uses a tasklet implementation for
sending mailbox messages.

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/include/plat/mailbox.h |    8 +++-
 arch/arm/plat-omap/mailbox.c              |   59 ++++++++--------------------
 2 files changed, 23 insertions(+), 44 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h
index bf06953..729166b 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/arch/arm/plat-omap/include/plat/mailbox.h
@@ -6,6 +6,7 @@
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 #include <linux/blkdev.h>
+#include <linux/interrupt.h>
 
 typedef u32 mbox_msg_t;
 struct omap_mbox;
@@ -28,8 +29,10 @@ struct omap_mbox_ops {
 	int		(*fifo_empty)(struct omap_mbox *mbox);
 	int		(*fifo_full)(struct omap_mbox *mbox);
 	/* irq */
-	void		(*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
-	void		(*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+	void		(*enable_irq)(struct omap_mbox *mbox,
+						omap_mbox_irq_t irq);
+	void		(*disable_irq)(struct omap_mbox *mbox,
+						omap_mbox_irq_t irq);
 	void		(*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	int		(*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	/* ctx */
@@ -41,6 +44,7 @@ struct omap_mbox_queue {
 	spinlock_t		lock;
 	struct request_queue	*queue;
 	struct work_struct	work;
+	struct tasklet_struct	tasklet;
 	int	(*callback)(void *);
 	struct omap_mbox	*mbox;
 };
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 4d7947e..8e90633 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -80,74 +80,45 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 	return ret;
 }
 
-struct omap_msg_tx_data {
-	mbox_msg_t	msg;
-};
-
-static void omap_msg_tx_end_io(struct request *rq, int error)
-{
-	kfree(rq->special);
-	__blk_put_request(rq->q, rq);
-}
 
 int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 {
-	struct omap_msg_tx_data *tx_data;
+
 	struct request *rq;
 	struct request_queue *q = mbox->txq->queue;
 
-	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
-	if (unlikely(!tx_data))
-		return -ENOMEM;
-
 	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
-	if (unlikely(!rq)) {
-		kfree(tx_data);
+	if (unlikely(!rq))
 		return -ENOMEM;
-	}
 
-	tx_data->msg = msg;
-	rq->end_io = omap_msg_tx_end_io;
-	blk_insert_request(q, rq, 0, tx_data);
+	blk_insert_request(q, rq, 0, (void *) msg);
+	tasklet_schedule(&mbox->txq->tasklet);
 
-	schedule_work(&mbox->txq->work);
 	return 0;
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);
 
-static void mbox_tx_work(struct work_struct *work)
+static void mbox_tx_tasklet(unsigned long tx_data)
 {
 	int ret;
 	struct request *rq;
-	struct omap_mbox_queue *mq = container_of(work,
-				struct omap_mbox_queue, work);
-	struct omap_mbox *mbox = mq->queue->queuedata;
+	struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
 	struct request_queue *q = mbox->txq->queue;
 
 	while (1) {
-		struct omap_msg_tx_data *tx_data;
 
-		spin_lock(q->queue_lock);
 		rq = blk_fetch_request(q);
-		spin_unlock(q->queue_lock);
 
 		if (!rq)
 			break;
 
-		tx_data = rq->special;
-
-		ret = __mbox_msg_send(mbox, tx_data->msg);
+		ret = __mbox_msg_send(mbox, (mbox_msg_t)rq->special);
 		if (ret) {
 			omap_mbox_enable_irq(mbox, IRQ_TX);
-			spin_lock(q->queue_lock);
 			blk_requeue_request(q, rq);
-			spin_unlock(q->queue_lock);
 			return;
 		}
-
-		spin_lock(q->queue_lock);
-		__blk_end_request_all(rq, 0);
-		spin_unlock(q->queue_lock);
+		blk_end_request_all(rq, 0);
 	}
 }
 
@@ -192,7 +163,7 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
 {
 	omap_mbox_disable_irq(mbox, IRQ_TX);
 	ack_mbox_irq(mbox, IRQ_TX);
-	schedule_work(&mbox->txq->work);
+	tasklet_schedule(&mbox->txq->tasklet);
 }
 
 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
@@ -235,7 +206,8 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
 
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 					request_fn_proc *proc,
-					void (*work) (struct work_struct *))
+					void (*work) (struct work_struct *),
+					void (*tasklet)(unsigned long))
 {
 	struct request_queue *q;
 	struct omap_mbox_queue *mq;
@@ -252,8 +224,11 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 	q->queuedata = mbox;
 	mq->queue = q;
 
-	INIT_WORK(&mq->work, work);
+	if (work)
+		INIT_WORK(&mq->work, work);
 
+	if (tasklet)
+		tasklet_init(&mq->tasklet, tasklet, (unsigned long)mbox);
 	return mq;
 error:
 	kfree(mq);
@@ -292,14 +267,14 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 		goto fail_request_irq;
 	}
 
-	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
+	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL, mbox_tx_tasklet);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_txq;
 	}
 	mbox->txq = mq;
 
-	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work);
+	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work, NULL);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_rxq;
-- 
1.5.3.2

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

* [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33
@ 2009-11-18 19:19 Tony Lindgren
  2009-11-18 19:20 ` [PATCH 01/10] omap: mailbox: Add build specific changes to support omap mailbox Tony Lindgren
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:19 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap

Hi all,

Here are omap4 related mailbox changes for review.

Regards,

Tony

---

C A Subramaniam (6):
      omap: mailbox: Add build specific changes to support omap mailbox
      omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox
      omap: mailbox: remove unnecessary arg for omap_mbox_msg_send
      omap: mailbox: Adds code changes to support OMAP4 mailbox
      omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED
      omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation

Hiroshi DOYU (4):
      omap: mailbox: remove sequence bit checking
      omap: mailbox: remove class interface
      omap: mailbox: remove disable_/enable_mbox_irq in isr
      omap: mailbox: Expose omap_mbox_enable()/disable_irq()


 arch/arm/mach-omap2/Makefile               |    3 
 arch/arm/mach-omap2/devices.c              |   36 +++-
 arch/arm/mach-omap2/mailbox.c              |  140 ++++++++++++--
 arch/arm/plat-omap/include/plat/mailbox.h  |   23 ++
 arch/arm/plat-omap/include/plat/omap44xx.h |    2 
 arch/arm/plat-omap/mailbox.c               |  282 +++++-----------------------
 6 files changed, 217 insertions(+), 269 deletions(-)

-- 
Signature

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

* [PATCH 01/10] omap: mailbox: Add build specific changes to support omap mailbox
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
@ 2009-11-18 19:20 ` Tony Lindgren
  2009-11-18 19:20 ` [PATCH 02/10] omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox Tony Lindgren
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:20 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Ramesh Gupta G, linux-omap, Hiroshi DOYU, C A Subramaniam

From: C A Subramaniam <subramaniam.ca@ti.com>

This patch adds changes to the build related files of mailbox
driver

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
Acked-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 5c32b65..b77fe24 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -44,6 +44,9 @@ obj-$(CONFIG_ARCH_OMAP4)		+= cm4xxx.o
 obj-$(CONFIG_ARCH_OMAP2)		+= clock24xx.o
 obj-$(CONFIG_ARCH_OMAP3)		+= clock34xx.o
 
+obj-$(CONFIG_OMAP_MBOX_FWK)		+= mailbox_mach.o
+mailbox_mach-objs			:= mailbox.o
+
 iommu-y					+= iommu2.o
 iommu-$(CONFIG_ARCH_OMAP3)		+= omap3-iommu.o
 


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

* [PATCH 02/10] omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
  2009-11-18 19:20 ` [PATCH 01/10] omap: mailbox: Add build specific changes to support omap mailbox Tony Lindgren
@ 2009-11-18 19:20 ` Tony Lindgren
  2009-11-18 19:20 ` [PATCH 03/10] omap: mailbox: remove sequence bit checking Tony Lindgren
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:20 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Ramesh Gupta G, linux-omap, Hiroshi DOYU, C A Subramaniam

From: C A Subramaniam <subramaniam.ca@ti.com>

This patch adds resource information of mailbox driver for
OMAP4 mailbox module. Register base address also added

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
Acked-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/devices.c              |   36 +++++++++++++++++++++-------
 arch/arm/plat-omap/include/plat/omap44xx.h |    2 ++
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 8b6cd8c..733d3dc 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -136,9 +136,10 @@ static inline void omap_init_camera(void)
 
 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
 
-#define MBOX_REG_SIZE	0x120
+#define MBOX_REG_SIZE   0x120
 
-static struct resource omap2_mbox_resources[] = {
+#ifdef CONFIG_ARCH_OMAP2
+static struct resource omap_mbox_resources[] = {
 	{
 		.start		= OMAP24XX_MAILBOX_BASE,
 		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
@@ -153,8 +154,10 @@ static struct resource omap2_mbox_resources[] = {
 		.flags		= IORESOURCE_IRQ,
 	},
 };
+#endif
 
-static struct resource omap3_mbox_resources[] = {
+#ifdef CONFIG_ARCH_OMAP3
+static struct resource omap_mbox_resources[] = {
 	{
 		.start		= OMAP34XX_MAILBOX_BASE,
 		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
@@ -165,6 +168,24 @@ static struct resource omap3_mbox_resources[] = {
 		.flags		= IORESOURCE_IRQ,
 	},
 };
+#endif
+
+#ifdef CONFIG_ARCH_OMAP4
+
+#define OMAP4_MBOX_REG_SIZE	0x130
+static struct resource omap_mbox_resources[] = {
+	{
+		.start          = OMAP44XX_MAILBOX_BASE,
+		.end            = OMAP44XX_MAILBOX_BASE +
+					OMAP4_MBOX_REG_SIZE - 1,
+		.flags          = IORESOURCE_MEM,
+	},
+	{
+		.start          = INT_44XX_MAIL_U0_MPU,
+		.flags          = IORESOURCE_IRQ,
+	},
+};
+#endif
 
 static struct platform_device mbox_device = {
 	.name		= "omap2-mailbox",
@@ -173,12 +194,9 @@ static struct platform_device mbox_device = {
 
 static inline void omap_init_mbox(void)
 {
-	if (cpu_is_omap2420()) {
-		mbox_device.num_resources = ARRAY_SIZE(omap2_mbox_resources);
-		mbox_device.resource = omap2_mbox_resources;
-	} else if (cpu_is_omap3430()) {
-		mbox_device.num_resources = ARRAY_SIZE(omap3_mbox_resources);
-		mbox_device.resource = omap3_mbox_resources;
+	if (cpu_is_omap2420() || cpu_is_omap3430() || cpu_is_omap44xx()) {
+		mbox_device.num_resources = ARRAY_SIZE(omap_mbox_resources);
+		mbox_device.resource = omap_mbox_resources;
 	} else {
 		pr_err("%s: platform not supported\n", __func__);
 		return;
diff --git a/arch/arm/plat-omap/include/plat/omap44xx.h b/arch/arm/plat-omap/include/plat/omap44xx.h
index 3361897..e52902a 100644
--- a/arch/arm/plat-omap/include/plat/omap44xx.h
+++ b/arch/arm/plat-omap/include/plat/omap44xx.h
@@ -40,5 +40,7 @@
 #define OMAP44XX_LOCAL_TWD_BASE		0x48240600
 #define OMAP44XX_WKUPGEN_BASE		0x48281000
 
+#define OMAP44XX_MAILBOX_BASE		(L4_44XX_BASE + 0xF4000)
+
 #endif /* __ASM_ARCH_OMAP44XX_H */
 


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

* [PATCH 03/10] omap: mailbox: remove sequence bit checking
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
  2009-11-18 19:20 ` [PATCH 01/10] omap: mailbox: Add build specific changes to support omap mailbox Tony Lindgren
  2009-11-18 19:20 ` [PATCH 02/10] omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox Tony Lindgren
@ 2009-11-18 19:20 ` Tony Lindgren
  2009-11-18 19:20 ` [PATCH 04/10] omap: mailbox: remove class interface Tony Lindgren
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:20 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Hiroshi DOYU

From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>

Any protocol should be handled in the upper layer and mailbox driver
shouldn't care about the contents of messages.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/mailbox.c |   70 ++----------------------------------------
 1 files changed, 4 insertions(+), 66 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 734bff3..f82810e 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -28,54 +28,9 @@
 
 #include <plat/mailbox.h>
 
-static int enable_seq_bit;
-module_param(enable_seq_bit, bool, 0);
-MODULE_PARM_DESC(enable_seq_bit, "Enable sequence bit checking.");
-
 static struct omap_mbox *mboxes;
 static DEFINE_RWLOCK(mboxes_lock);
 
-/*
- * Mailbox sequence bit API
- */
-
-/* seq_rcv should be initialized with any value other than
- * 0 and 1 << 31, to allow either value for the first
- * message.  */
-static inline void mbox_seq_init(struct omap_mbox *mbox)
-{
-	if (!enable_seq_bit)
-		return;
-
-	/* any value other than 0 and 1 << 31 */
-	mbox->seq_rcv = 0xffffffff;
-}
-
-static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
-{
-	if (!enable_seq_bit)
-		return;
-
-	/* add seq_snd to msg */
-	*msg = (*msg & 0x7fffffff) | mbox->seq_snd;
-	/* flip seq_snd */
-	mbox->seq_snd ^= 1 << 31;
-}
-
-static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
-{
-	mbox_msg_t seq;
-
-	if (!enable_seq_bit)
-		return 0;
-
-	seq = msg & (1 << 31);
-	if (seq == mbox->seq_rcv)
-		return -1;
-	mbox->seq_rcv = seq;
-	return 0;
-}
-
 /* Mailbox FIFO handle functions */
 static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
 {
@@ -113,13 +68,6 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
 	return mbox->ops->is_irq(mbox, irq);
 }
 
-/* Mailbox Sequence Bit function */
-void omap_mbox_init_seq(struct omap_mbox *mbox)
-{
-	mbox_seq_init(mbox);
-}
-EXPORT_SYMBOL(omap_mbox_init_seq);
-
 /*
  * message sender
  */
@@ -141,7 +89,6 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void *arg)
 			goto out;
 	}
 
-	mbox_seq_toggle(mbox, &msg);
 	mbox_fifo_write(mbox, msg);
  out:
 	return ret;
@@ -254,11 +201,11 @@ static void mbox_rx_work(struct work_struct *work)
 /*
  * Mailbox interrupt handler
  */
-static void mbox_txq_fn(struct request_queue * q)
+static void mbox_txq_fn(struct request_queue *q)
 {
 }
 
-static void mbox_rxq_fn(struct request_queue * q)
+static void mbox_rxq_fn(struct request_queue *q)
 {
 }
 
@@ -284,11 +231,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 
 		msg = mbox_fifo_read(mbox);
 
-		if (unlikely(mbox_seq_test(mbox, msg))) {
-			pr_info("mbox: Illegal seq bit!(%08x)\n", msg);
-			if (mbox->err_notify)
-				mbox->err_notify();
-		}
 
 		blk_insert_request(q, rq, 0, (void *)msg);
 		if (mbox->ops->type == OMAP_MBOX_TYPE1)
@@ -320,7 +262,7 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
  */
 static ssize_t
 omap_mbox_write(struct device *dev, struct device_attribute *attr,
-		const char * buf, size_t count)
+		const char *buf, size_t count)
 {
 	int ret;
 	mbox_msg_t *p = (mbox_msg_t *)buf;
@@ -357,10 +299,6 @@ omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)
 
 		blk_end_request_all(rq, 0);
 
-		if (unlikely(mbox_seq_test(mbox, *p))) {
-			pr_info("mbox: Illegal seq bit!(%08x) ignored\n", *p);
-			continue;
-		}
 		p++;
 	}
 
@@ -383,7 +321,7 @@ static struct class omap_mbox_class = {
 };
 
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
-					request_fn_proc * proc,
+					request_fn_proc *proc,
 					void (*work) (struct work_struct *))
 {
 	struct request_queue *q;


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

* [PATCH 04/10] omap: mailbox: remove class interface
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (2 preceding siblings ...)
  2009-11-18 19:20 ` [PATCH 03/10] omap: mailbox: remove sequence bit checking Tony Lindgren
@ 2009-11-18 19:20 ` Tony Lindgren
  2009-11-18 19:20 ` [PATCH 05/10] omap: mailbox: remove disable_/enable_mbox_irq in isr Tony Lindgren
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:20 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Hiroshi DOYU

From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>

It's not used at present.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/include/plat/mailbox.h |    1 
 arch/arm/plat-omap/mailbox.c              |  115 ++---------------------------
 2 files changed, 9 insertions(+), 107 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h
index b7a6991..319306a 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/arch/arm/plat-omap/include/plat/mailbox.h
@@ -8,7 +8,6 @@
 #include <linux/blkdev.h>
 
 typedef u32 mbox_msg_t;
-typedef void (mbox_receiver_t)(mbox_msg_t msg);
 struct omap_mbox;
 
 typedef int __bitwise omap_mbox_irq_t;
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index f82810e..13ca236 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -71,7 +71,7 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
 /*
  * message sender
  */
-static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void *arg)
+static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 {
 	int ret = 0, i = 1000;
 
@@ -82,15 +82,7 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void *arg)
 			return -1;
 		udelay(1);
 	}
-
-	if (arg && mbox->txq->callback) {
-		ret = mbox->txq->callback(arg);
-		if (ret)
-			goto out;
-	}
-
 	mbox_fifo_write(mbox, msg);
- out:
 	return ret;
 }
 
@@ -152,7 +144,7 @@ static void mbox_tx_work(struct work_struct *work)
 
 		tx_data = rq->special;
 
-		ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg);
+		ret = __mbox_msg_send(mbox, tx_data->msg);
 		if (ret) {
 			enable_mbox_irq(mbox, IRQ_TX);
 			spin_lock(q->queue_lock);
@@ -180,11 +172,6 @@ static void mbox_rx_work(struct work_struct *work)
 	mbox_msg_t msg;
 	unsigned long flags;
 
-	if (mbox->rxq->callback == NULL) {
-		sysfs_notify(&mbox->dev->kobj, NULL, "mbox");
-		return;
-	}
-
 	while (1) {
 		spin_lock_irqsave(q->queue_lock, flags);
 		rq = blk_fetch_request(q);
@@ -257,69 +244,6 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
 	return IRQ_HANDLED;
 }
 
-/*
- * sysfs files
- */
-static ssize_t
-omap_mbox_write(struct device *dev, struct device_attribute *attr,
-		const char *buf, size_t count)
-{
-	int ret;
-	mbox_msg_t *p = (mbox_msg_t *)buf;
-	struct omap_mbox *mbox = dev_get_drvdata(dev);
-
-	for (; count >= sizeof(mbox_msg_t); count -= sizeof(mbox_msg_t)) {
-		ret = omap_mbox_msg_send(mbox, be32_to_cpu(*p), NULL);
-		if (ret)
-			return -EAGAIN;
-		p++;
-	}
-
-	return (size_t)((char *)p - buf);
-}
-
-static ssize_t
-omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)
-{
-	unsigned long flags;
-	struct request *rq;
-	mbox_msg_t *p = (mbox_msg_t *) buf;
-	struct omap_mbox *mbox = dev_get_drvdata(dev);
-	struct request_queue *q = mbox->rxq->queue;
-
-	while (1) {
-		spin_lock_irqsave(q->queue_lock, flags);
-		rq = blk_fetch_request(q);
-		spin_unlock_irqrestore(q->queue_lock, flags);
-
-		if (!rq)
-			break;
-
-		*p = (mbox_msg_t)rq->special;
-
-		blk_end_request_all(rq, 0);
-
-		p++;
-	}
-
-	pr_debug("%02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3]);
-
-	return (size_t) ((char *)p - buf);
-}
-
-static DEVICE_ATTR(mbox, S_IRUGO | S_IWUSR, omap_mbox_read, omap_mbox_write);
-
-static ssize_t mbox_show(struct class *class, char *buf)
-{
-	return sprintf(buf, "mbox");
-}
-
-static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL);
-
-static struct class omap_mbox_class = {
-	.name = "omap-mailbox",
-};
-
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 					request_fn_proc *proc,
 					void (*work) (struct work_struct *))
@@ -353,7 +277,7 @@ static void mbox_queue_free(struct omap_mbox_queue *q)
 	kfree(q);
 }
 
-static int omap_mbox_init(struct omap_mbox *mbox)
+static int omap_mbox_startup(struct omap_mbox *mbox)
 {
 	int ret;
 	struct omap_mbox_queue *mq;
@@ -436,7 +360,7 @@ struct omap_mbox *omap_mbox_get(const char *name)
 
 	read_unlock(&mboxes_lock);
 
-	ret = omap_mbox_init(mbox);
+	ret = omap_mbox_startup(mbox);
 	if (ret)
 		return ERR_PTR(-ENODEV);
 
@@ -460,15 +384,6 @@ int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 	if (mbox->next)
 		return -EBUSY;
 
-	mbox->dev = device_create(&omap_mbox_class,
-				  parent, 0, mbox, "%s", mbox->name);
-	if (IS_ERR(mbox->dev))
-		return PTR_ERR(mbox->dev);
-
-	ret = device_create_file(mbox->dev, &dev_attr_mbox);
-	if (ret)
-		goto err_sysfs;
-
 	write_lock(&mboxes_lock);
 	tmp = find_mboxes(mbox->name);
 	if (*tmp) {
@@ -482,9 +397,6 @@ int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 	return 0;
 
 err_find:
-	device_remove_file(mbox->dev, &dev_attr_mbox);
-err_sysfs:
-	device_unregister(mbox->dev);
 	return ret;
 }
 EXPORT_SYMBOL(omap_mbox_register);
@@ -500,8 +412,6 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
 			*tmp = mbox->next;
 			mbox->next = NULL;
 			write_unlock(&mboxes_lock);
-			device_remove_file(mbox->dev, &dev_attr_mbox);
-			device_unregister(mbox->dev);
 			return 0;
 		}
 		tmp = &(*tmp)->next;
@@ -512,23 +422,16 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
 }
 EXPORT_SYMBOL(omap_mbox_unregister);
 
-static int __init omap_mbox_class_init(void)
+static int __init omap_mbox_init(void)
 {
-	int ret = class_register(&omap_mbox_class);
-	if (!ret)
-		ret = class_create_file(&omap_mbox_class, &class_attr_mbox);
-
-	return ret;
+	return 0;
 }
+module_init(omap_mbox_init);
 
-static void __exit omap_mbox_class_exit(void)
+static void __exit omap_mbox_exit(void)
 {
-	class_remove_file(&omap_mbox_class, &class_attr_mbox);
-	class_unregister(&omap_mbox_class);
 }
-
-subsys_initcall(omap_mbox_class_init);
-module_exit(omap_mbox_class_exit);
+module_exit(omap_mbox_exit);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("omap mailbox: interrupt driven messaging");


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

* [PATCH 05/10] omap: mailbox: remove disable_/enable_mbox_irq in isr
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (3 preceding siblings ...)
  2009-11-18 19:20 ` [PATCH 04/10] omap: mailbox: remove class interface Tony Lindgren
@ 2009-11-18 19:20 ` Tony Lindgren
  2009-11-18 19:21 ` [PATCH 06/10] omap: mailbox: remove unnecessary arg for omap_mbox_msg_send Tony Lindgren
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:20 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Hiroshi DOYU

From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>

No need to handle it in isr, since irq won't happen during isr.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/mailbox.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 13ca236..b49bb29 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -209,8 +209,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 	mbox_msg_t msg;
 	struct request_queue *q = mbox->rxq->queue;
 
-	disable_mbox_irq(mbox, IRQ_RX);
-
 	while (!mbox_fifo_empty(mbox)) {
 		rq = blk_get_request(q, WRITE, GFP_ATOMIC);
 		if (unlikely(!rq))
@@ -226,7 +224,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 
 	/* no more messages in the fifo. clear IRQ source. */
 	ack_mbox_irq(mbox, IRQ_RX);
-	enable_mbox_irq(mbox, IRQ_RX);
 nomem:
 	schedule_work(&mbox->rxq->work);
 }


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

* [PATCH 06/10] omap: mailbox: remove unnecessary arg for omap_mbox_msg_send
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (4 preceding siblings ...)
  2009-11-18 19:20 ` [PATCH 05/10] omap: mailbox: remove disable_/enable_mbox_irq in isr Tony Lindgren
@ 2009-11-18 19:21 ` Tony Lindgren
  2009-11-18 19:21 ` [PATCH 07/10] omap: mailbox: Expose omap_mbox_enable()/disable_irq() Tony Lindgren
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:21 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Hiroshi DOYU, C A Subramaniam

From: C A Subramaniam <subramaniam.ca@ti.com>

Also removed from tx_data

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Acked-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/include/plat/mailbox.h |    2 +-
 arch/arm/plat-omap/mailbox.c              |    4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h
index 319306a..8260a3f 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/arch/arm/plat-omap/include/plat/mailbox.h
@@ -63,7 +63,7 @@ struct omap_mbox {
 	void			(*err_notify)(void);
 };
 
-int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg, void *);
+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 *);
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index b49bb29..99ecf80 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -88,7 +88,6 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 
 struct omap_msg_tx_data {
 	mbox_msg_t	msg;
-	void		*arg;
 };
 
 static void omap_msg_tx_end_io(struct request *rq, int error)
@@ -97,7 +96,7 @@ static void omap_msg_tx_end_io(struct request *rq, int error)
 	__blk_put_request(rq->q, rq);
 }
 
-int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void* arg)
+int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 {
 	struct omap_msg_tx_data *tx_data;
 	struct request *rq;
@@ -114,7 +113,6 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void* arg)
 	}
 
 	tx_data->msg = msg;
-	tx_data->arg = arg;
 	rq->end_io = omap_msg_tx_end_io;
 	blk_insert_request(q, rq, 0, tx_data);
 


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

* [PATCH 07/10] omap: mailbox: Expose omap_mbox_enable()/disable_irq()
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (5 preceding siblings ...)
  2009-11-18 19:21 ` [PATCH 06/10] omap: mailbox: remove unnecessary arg for omap_mbox_msg_send Tony Lindgren
@ 2009-11-18 19:21 ` Tony Lindgren
  2009-11-18 19:21 ` [PATCH 08/10] omap: mailbox: Adds code changes to support OMAP4 mailbox Tony Lindgren
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:21 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-omap, Hiroshi DOYU

From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>

Expose omap_mbox_enable()/disable_irq()

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/include/plat/mailbox.h |   12 ++++++++++++
 arch/arm/plat-omap/mailbox.c              |   12 ++----------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h
index 8260a3f..bf06953 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/arch/arm/plat-omap/include/plat/mailbox.h
@@ -92,4 +92,16 @@ static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
 	mbox->ops->restore_ctx(mbox);
 }
 
+static inline void omap_mbox_enable_irq(struct omap_mbox *mbox,
+					omap_mbox_irq_t irq)
+{
+	mbox->ops->enable_irq(mbox, irq);
+}
+
+static inline void omap_mbox_disable_irq(struct omap_mbox *mbox,
+					 omap_mbox_irq_t irq)
+{
+	mbox->ops->disable_irq(mbox, irq);
+}
+
 #endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 99ecf80..e6b3115 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -50,14 +50,6 @@ static inline int mbox_fifo_full(struct omap_mbox *mbox)
 }
 
 /* Mailbox IRQ handle functions */
-static inline void enable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
-	mbox->ops->enable_irq(mbox, irq);
-}
-static inline void disable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
-	mbox->ops->disable_irq(mbox, irq);
-}
 static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
 {
 	if (mbox->ops->ack_irq)
@@ -144,7 +136,7 @@ static void mbox_tx_work(struct work_struct *work)
 
 		ret = __mbox_msg_send(mbox, tx_data->msg);
 		if (ret) {
-			enable_mbox_irq(mbox, IRQ_TX);
+			omap_mbox_enable_irq(mbox, IRQ_TX);
 			spin_lock(q->queue_lock);
 			blk_requeue_request(q, rq);
 			spin_unlock(q->queue_lock);
@@ -196,7 +188,7 @@ static void mbox_rxq_fn(struct request_queue *q)
 
 static void __mbox_tx_interrupt(struct omap_mbox *mbox)
 {
-	disable_mbox_irq(mbox, IRQ_TX);
+	omap_mbox_disable_irq(mbox, IRQ_TX);
 	ack_mbox_irq(mbox, IRQ_TX);
 	schedule_work(&mbox->txq->work);
 }


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

* [PATCH 08/10] omap: mailbox: Adds code changes to support OMAP4 mailbox
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (6 preceding siblings ...)
  2009-11-18 19:21 ` [PATCH 07/10] omap: mailbox: Expose omap_mbox_enable()/disable_irq() Tony Lindgren
@ 2009-11-18 19:21 ` Tony Lindgren
  2009-11-18 19:21 ` [PATCH 09/10] omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED Tony Lindgren
  2009-11-18 19:21 ` [PATCH 10/10] omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation Tony Lindgren
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Hari Kanigeri, Ramesh Gupta G, linux-omap, Hiroshi DOYU,
	C A Subramaniam

From: C A Subramaniam <subramaniam.ca@ti.com>

This patch adds code changes in the mailbox driver module to
add support for OMAP4 mailbox.

Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/mailbox.c |  140 ++++++++++++++++++++++++++++++++++-------
 arch/arm/plat-omap/mailbox.c  |   25 ++++++-
 2 files changed, 136 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 5ba3aa6..281ab63 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -18,6 +18,8 @@
 #include <plat/mailbox.h>
 #include <mach/irqs.h>
 
+#define DRV_NAME "omap2-mailbox"
+
 #define MAILBOX_REVISION		0x000
 #define MAILBOX_SYSCONFIG		0x010
 #define MAILBOX_SYSSTATUS		0x014
@@ -27,8 +29,12 @@
 #define MAILBOX_IRQSTATUS(u)		(0x100 + 8 * (u))
 #define MAILBOX_IRQENABLE(u)		(0x104 + 8 * (u))
 
-#define MAILBOX_IRQ_NEWMSG(u)		(1 << (2 * (u)))
-#define MAILBOX_IRQ_NOTFULL(u)		(1 << (2 * (u) + 1))
+#define OMAP4_MAILBOX_IRQSTATUS(u)	(0x104 + 10 * (u))
+#define OMAP4_MAILBOX_IRQENABLE(u)	(0x108 + 10 * (u))
+#define OMAP4_MAILBOX_IRQENABLE_CLR(u)	(0x10c + 10 * (u))
+
+#define MAILBOX_IRQ_NEWMSG(m)		(1 << (2 * (m)))
+#define MAILBOX_IRQ_NOTFULL(m)		(1 << (2 * (m) + 1))
 
 /* SYSCONFIG: register bit definition */
 #define AUTOIDLE	(1 << 0)
@@ -39,7 +45,11 @@
 #define RESETDONE	(1 << 0)
 
 #define MBOX_REG_SIZE			0x120
+
+#define OMAP4_MBOX_REG_SIZE		0x130
+
 #define MBOX_NR_REGS			(MBOX_REG_SIZE / sizeof(u32))
+#define OMAP4_MBOX_NR_REGS		(OMAP4_MBOX_REG_SIZE / sizeof(u32))
 
 static void __iomem *mbox_base;
 
@@ -56,7 +66,8 @@ struct omap_mbox2_priv {
 	unsigned long irqstatus;
 	u32 newmsg_bit;
 	u32 notfull_bit;
-	u32 ctx[MBOX_NR_REGS];
+	u32 ctx[OMAP4_MBOX_NR_REGS];
+	unsigned long irqdisable;
 };
 
 static struct clk *mbox_ick_handle;
@@ -82,8 +93,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
 
 	mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
 	if (IS_ERR(mbox_ick_handle)) {
-		pr_err("Can't get mailboxes_ick\n");
-		return -ENODEV;
+		printk(KERN_ERR "Could not get mailboxes_ick: %d\n",
+			PTR_ERR(mbox_ick_handle));
+		return PTR_ERR(mbox_ick_handle);
 	}
 	clk_enable(mbox_ick_handle);
 
@@ -115,6 +127,7 @@ static void omap2_mbox_shutdown(struct omap_mbox *mbox)
 {
 	clk_disable(mbox_ick_handle);
 	clk_put(mbox_ick_handle);
+	mbox_ick_handle = NULL;
 }
 
 /* Mailbox FIFO handle functions */
@@ -143,7 +156,7 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox)
 {
 	struct omap_mbox2_fifo *fifo =
 		&((struct omap_mbox2_priv *)mbox->priv)->tx_fifo;
-	return (mbox_read_reg(fifo->fifo_stat));
+	return mbox_read_reg(fifo->fifo_stat);
 }
 
 /* Mailbox IRQ handle functions */
@@ -163,10 +176,9 @@ 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->irqenable);
+	l = mbox_read_reg(p->irqdisable);
 	l &= ~bit;
-	mbox_write_reg(l, p->irqenable);
+	mbox_write_reg(l, p->irqdisable);
 }
 
 static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
@@ -189,15 +201,19 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
 	u32 enable = mbox_read_reg(p->irqenable);
 	u32 status = mbox_read_reg(p->irqstatus);
 
-	return (enable & status & bit);
+	return (int)(enable & status & bit);
 }
 
 static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
 {
 	int i;
 	struct omap_mbox2_priv *p = mbox->priv;
-
-	for (i = 0; i < MBOX_NR_REGS; i++) {
+	int nr_regs;
+	if (cpu_is_omap44xx())
+		nr_regs = OMAP4_MBOX_NR_REGS;
+	else
+		nr_regs = MBOX_NR_REGS;
+	for (i = 0; i < nr_regs; i++) {
 		p->ctx[i] = mbox_read_reg(i * sizeof(u32));
 
 		dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
@@ -209,8 +225,12 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
 {
 	int i;
 	struct omap_mbox2_priv *p = mbox->priv;
-
-	for (i = 0; i < MBOX_NR_REGS; i++) {
+	int nr_regs;
+	if (cpu_is_omap44xx())
+		nr_regs = OMAP4_MBOX_NR_REGS;
+	else
+		nr_regs = MBOX_NR_REGS;
+	for (i = 0; i < nr_regs; i++) {
 		mbox_write_reg(p->ctx[i], i * sizeof(u32));
 
 		dev_dbg(mbox->dev, "%s: [%02x] %08x\n", __func__,
@@ -242,7 +262,6 @@ static struct omap_mbox_ops omap2_mbox_ops = {
  */
 
 /* FIXME: the following structs should be filled automatically by the user id */
-
 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.tx_fifo = {
@@ -257,8 +276,36 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.irqstatus	= MAILBOX_IRQSTATUS(0),
 	.notfull_bit	= MAILBOX_IRQ_NOTFULL(0),
 	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(1),
+	.irqdisable	= MAILBOX_IRQENABLE(0),
+};
+
+
+
+/* OMAP4 specific data structure. Use the cpu_is_omap4xxx()
+to use this*/
+static struct omap_mbox2_priv omap2_mbox_1_priv = {
+	.tx_fifo = {
+		.msg		= MAILBOX_MESSAGE(0),
+		.fifo_stat	= MAILBOX_FIFOSTATUS(0),
+	},
+	.rx_fifo = {
+		.msg		= MAILBOX_MESSAGE(1),
+		.msg_stat	= MAILBOX_MSGSTATUS(1),
+	},
+	.irqenable	= OMAP4_MAILBOX_IRQENABLE(0),
+	.irqstatus	= OMAP4_MAILBOX_IRQSTATUS(0),
+	.notfull_bit	= MAILBOX_IRQ_NOTFULL(0),
+	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(1),
+	.irqdisable	= OMAP4_MAILBOX_IRQENABLE_CLR(0),
 };
 
+struct omap_mbox mbox_1_info = {
+	.name	= "mailbox-1",
+	.ops	= &omap2_mbox_ops,
+	.priv	= &omap2_mbox_1_priv,
+};
+EXPORT_SYMBOL(mbox_1_info);
+
 struct omap_mbox mbox_dsp_info = {
 	.name	= "dsp",
 	.ops	= &omap2_mbox_ops,
@@ -266,6 +313,30 @@ struct omap_mbox mbox_dsp_info = {
 };
 EXPORT_SYMBOL(mbox_dsp_info);
 
+static struct omap_mbox2_priv omap2_mbox_2_priv = {
+	.tx_fifo = {
+		.msg		= MAILBOX_MESSAGE(3),
+		.fifo_stat	= MAILBOX_FIFOSTATUS(3),
+	},
+	.rx_fifo = {
+		.msg		= MAILBOX_MESSAGE(2),
+		.msg_stat	= MAILBOX_MSGSTATUS(2),
+	},
+	.irqenable	= OMAP4_MAILBOX_IRQENABLE(0),
+	.irqstatus	= OMAP4_MAILBOX_IRQSTATUS(0),
+	.notfull_bit	= MAILBOX_IRQ_NOTFULL(3),
+	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(2),
+	.irqdisable     = OMAP4_MAILBOX_IRQENABLE_CLR(0),
+};
+
+struct omap_mbox mbox_2_info = {
+	.name	= "mailbox-2",
+	.ops	= &omap2_mbox_ops,
+	.priv	= &omap2_mbox_2_priv,
+};
+EXPORT_SYMBOL(mbox_2_info);
+
+
 #if defined(CONFIG_ARCH_OMAP2420) /* IVA */
 static struct omap_mbox2_priv omap2_mbox_iva_priv = {
 	.tx_fifo = {
@@ -280,6 +351,7 @@ static struct omap_mbox2_priv omap2_mbox_iva_priv = {
 	.irqstatus	= MAILBOX_IRQSTATUS(3),
 	.notfull_bit	= MAILBOX_IRQ_NOTFULL(2),
 	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(3),
+	.irqdisable	= MAILBOX_IRQENABLE(3),
 };
 
 static struct omap_mbox mbox_iva_info = {
@@ -305,17 +377,31 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* DSP or IVA2 IRQ */
-	ret = platform_get_irq(pdev, 0);
-	if (ret < 0) {
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+
+	if (unlikely(!res)) {
 		dev_err(&pdev->dev, "invalid irq resource\n");
+		ret = -ENODEV;
 		goto err_dsp;
 	}
-	mbox_dsp_info.irq = ret;
-
-	ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
+	if (cpu_is_omap44xx()) {
+		mbox_1_info.irq = res->start;
+		ret = omap_mbox_register(&pdev->dev, &mbox_1_info);
+	} else {
+		mbox_dsp_info.irq = res->start;
+		ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
+	}
 	if (ret)
 		goto err_dsp;
 
+	if (cpu_is_omap44xx()) {
+		mbox_2_info.irq = res->start;
+		ret = omap_mbox_register(&pdev->dev, &mbox_2_info);
+		if (ret) {
+			omap_mbox_unregister(&mbox_1_info);
+			goto err_dsp;
+		}
+	}
 #if defined(CONFIG_ARCH_OMAP2420) /* IVA */
 	if (cpu_is_omap2420()) {
 		/* IVA IRQ */
@@ -335,6 +421,7 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 
 err_iva1:
 	omap_mbox_unregister(&mbox_dsp_info);
+
 err_dsp:
 	iounmap(mbox_base);
 	return ret;
@@ -345,7 +432,12 @@ static int __devexit omap2_mbox_remove(struct platform_device *pdev)
 #if defined(CONFIG_ARCH_OMAP2420)
 	omap_mbox_unregister(&mbox_iva_info);
 #endif
-	omap_mbox_unregister(&mbox_dsp_info);
+
+	if (cpu_is_omap44xx()) {
+		omap_mbox_unregister(&mbox_2_info);
+		omap_mbox_unregister(&mbox_1_info);
+	} else
+		omap_mbox_unregister(&mbox_dsp_info);
 	iounmap(mbox_base);
 	return 0;
 }
@@ -354,7 +446,7 @@ static struct platform_driver omap2_mbox_driver = {
 	.probe = omap2_mbox_probe,
 	.remove = __devexit_p(omap2_mbox_remove),
 	.driver = {
-		.name = "omap2-mailbox",
+		.name = DRV_NAME,
 	},
 };
 
@@ -372,6 +464,6 @@ module_init(omap2_mbox_init);
 module_exit(omap2_mbox_exit);
 
 MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions");
+MODULE_DESCRIPTION("omap mailbox: omap2/3/4 architecture specific functions");
 MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>, Paul Mundt");
-MODULE_ALIAS("platform:omap2-mailbox");
+MODULE_ALIAS("platform:"DRV_NAME);
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index e6b3115..2210c45 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -31,6 +31,8 @@
 static struct omap_mbox *mboxes;
 static DEFINE_RWLOCK(mboxes_lock);
 
+static int mbox_configured;
+
 /* Mailbox FIFO handle functions */
 static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
 {
@@ -266,13 +268,20 @@ static void mbox_queue_free(struct omap_mbox_queue *q)
 
 static int omap_mbox_startup(struct omap_mbox *mbox)
 {
-	int ret;
+	int ret = 0;
 	struct omap_mbox_queue *mq;
 
 	if (likely(mbox->ops->startup)) {
-		ret = mbox->ops->startup(mbox);
-		if (unlikely(ret))
+		write_lock(&mboxes_lock);
+		if (!mbox_configured)
+			ret = mbox->ops->startup(mbox);
+
+		if (unlikely(ret)) {
+			write_unlock(&mboxes_lock);
 			return ret;
+		}
+		mbox_configured++;
+		write_unlock(&mboxes_lock);
 	}
 
 	ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED,
@@ -317,8 +326,14 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
 
 	free_irq(mbox->irq, mbox);
 
-	if (unlikely(mbox->ops->shutdown))
-		mbox->ops->shutdown(mbox);
+	if (unlikely(mbox->ops->shutdown)) {
+		write_lock(&mboxes_lock);
+		if (mbox_configured > 0)
+			mbox_configured--;
+		if (!mbox_configured)
+			mbox->ops->shutdown(mbox);
+		write_unlock(&mboxes_lock);
+	}
 }
 
 static struct omap_mbox **find_mboxes(const char *name)


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

* [PATCH 09/10] omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (7 preceding siblings ...)
  2009-11-18 19:21 ` [PATCH 08/10] omap: mailbox: Adds code changes to support OMAP4 mailbox Tony Lindgren
@ 2009-11-18 19:21 ` Tony Lindgren
  2009-11-18 19:21 ` [PATCH 10/10] omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation Tony Lindgren
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Ramesh Gupta G, linux-omap, Hiroshi DOYU, C A Subramaniam

From: C A Subramaniam <subramaniam.ca@ti.com>

Currently, this facilitates both the tesla and ducati
sides to request for the same irq through an
omap_mbox_get() call.

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
Acked-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/mailbox.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 2210c45..4d7947e 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -284,7 +284,7 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 		write_unlock(&mboxes_lock);
 	}
 
-	ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED,
+	ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
 				mbox->name, mbox);
 	if (unlikely(ret)) {
 		printk(KERN_ERR


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

* [PATCH 10/10] omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation
  2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
                   ` (8 preceding siblings ...)
  2009-11-18 19:21 ` [PATCH 09/10] omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED Tony Lindgren
@ 2009-11-18 19:21 ` Tony Lindgren
  9 siblings, 0 replies; 21+ messages in thread
From: Tony Lindgren @ 2009-11-18 19:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Ramesh Gupta G, linux-omap, Hiroshi DOYU, C A Subramaniam

From: C A Subramaniam <subramaniam.ca@ti.com>

This patch uses a tasklet implementation for
sending mailbox messages.

Signed-off-by: C A Subramaniam <subramaniam.ca@ti.com>
Signed-off-by: Ramesh Gupta G <grgupta@ti.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/include/plat/mailbox.h |    8 +++-
 arch/arm/plat-omap/mailbox.c              |   59 ++++++++---------------------
 2 files changed, 23 insertions(+), 44 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h
index bf06953..729166b 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/arch/arm/plat-omap/include/plat/mailbox.h
@@ -6,6 +6,7 @@
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 #include <linux/blkdev.h>
+#include <linux/interrupt.h>
 
 typedef u32 mbox_msg_t;
 struct omap_mbox;
@@ -28,8 +29,10 @@ struct omap_mbox_ops {
 	int		(*fifo_empty)(struct omap_mbox *mbox);
 	int		(*fifo_full)(struct omap_mbox *mbox);
 	/* irq */
-	void		(*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
-	void		(*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+	void		(*enable_irq)(struct omap_mbox *mbox,
+						omap_mbox_irq_t irq);
+	void		(*disable_irq)(struct omap_mbox *mbox,
+						omap_mbox_irq_t irq);
 	void		(*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	int		(*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	/* ctx */
@@ -41,6 +44,7 @@ struct omap_mbox_queue {
 	spinlock_t		lock;
 	struct request_queue	*queue;
 	struct work_struct	work;
+	struct tasklet_struct	tasklet;
 	int	(*callback)(void *);
 	struct omap_mbox	*mbox;
 };
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 4d7947e..8e90633 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -80,74 +80,45 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 	return ret;
 }
 
-struct omap_msg_tx_data {
-	mbox_msg_t	msg;
-};
-
-static void omap_msg_tx_end_io(struct request *rq, int error)
-{
-	kfree(rq->special);
-	__blk_put_request(rq->q, rq);
-}
 
 int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
 {
-	struct omap_msg_tx_data *tx_data;
+
 	struct request *rq;
 	struct request_queue *q = mbox->txq->queue;
 
-	tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
-	if (unlikely(!tx_data))
-		return -ENOMEM;
-
 	rq = blk_get_request(q, WRITE, GFP_ATOMIC);
-	if (unlikely(!rq)) {
-		kfree(tx_data);
+	if (unlikely(!rq))
 		return -ENOMEM;
-	}
 
-	tx_data->msg = msg;
-	rq->end_io = omap_msg_tx_end_io;
-	blk_insert_request(q, rq, 0, tx_data);
+	blk_insert_request(q, rq, 0, (void *) msg);
+	tasklet_schedule(&mbox->txq->tasklet);
 
-	schedule_work(&mbox->txq->work);
 	return 0;
 }
 EXPORT_SYMBOL(omap_mbox_msg_send);
 
-static void mbox_tx_work(struct work_struct *work)
+static void mbox_tx_tasklet(unsigned long tx_data)
 {
 	int ret;
 	struct request *rq;
-	struct omap_mbox_queue *mq = container_of(work,
-				struct omap_mbox_queue, work);
-	struct omap_mbox *mbox = mq->queue->queuedata;
+	struct omap_mbox *mbox = (struct omap_mbox *)tx_data;
 	struct request_queue *q = mbox->txq->queue;
 
 	while (1) {
-		struct omap_msg_tx_data *tx_data;
 
-		spin_lock(q->queue_lock);
 		rq = blk_fetch_request(q);
-		spin_unlock(q->queue_lock);
 
 		if (!rq)
 			break;
 
-		tx_data = rq->special;
-
-		ret = __mbox_msg_send(mbox, tx_data->msg);
+		ret = __mbox_msg_send(mbox, (mbox_msg_t)rq->special);
 		if (ret) {
 			omap_mbox_enable_irq(mbox, IRQ_TX);
-			spin_lock(q->queue_lock);
 			blk_requeue_request(q, rq);
-			spin_unlock(q->queue_lock);
 			return;
 		}
-
-		spin_lock(q->queue_lock);
-		__blk_end_request_all(rq, 0);
-		spin_unlock(q->queue_lock);
+		blk_end_request_all(rq, 0);
 	}
 }
 
@@ -192,7 +163,7 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
 {
 	omap_mbox_disable_irq(mbox, IRQ_TX);
 	ack_mbox_irq(mbox, IRQ_TX);
-	schedule_work(&mbox->txq->work);
+	tasklet_schedule(&mbox->txq->tasklet);
 }
 
 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
@@ -235,7 +206,8 @@ static irqreturn_t mbox_interrupt(int irq, void *p)
 
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 					request_fn_proc *proc,
-					void (*work) (struct work_struct *))
+					void (*work) (struct work_struct *),
+					void (*tasklet)(unsigned long))
 {
 	struct request_queue *q;
 	struct omap_mbox_queue *mq;
@@ -252,8 +224,11 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
 	q->queuedata = mbox;
 	mq->queue = q;
 
-	INIT_WORK(&mq->work, work);
+	if (work)
+		INIT_WORK(&mq->work, work);
 
+	if (tasklet)
+		tasklet_init(&mq->tasklet, tasklet, (unsigned long)mbox);
 	return mq;
 error:
 	kfree(mq);
@@ -292,14 +267,14 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 		goto fail_request_irq;
 	}
 
-	mq = mbox_queue_alloc(mbox, mbox_txq_fn, mbox_tx_work);
+	mq = mbox_queue_alloc(mbox, mbox_txq_fn, NULL, mbox_tx_tasklet);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_txq;
 	}
 	mbox->txq = mq;
 
-	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work);
+	mq = mbox_queue_alloc(mbox, mbox_rxq_fn, mbox_rx_work, NULL);
 	if (!mq) {
 		ret = -ENOMEM;
 		goto fail_alloc_rxq;


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

end of thread, other threads:[~2009-11-18 19:21 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18 19:19 [PATCH 00/10] Omap mailbox updates for omap4 for 2.6.33 Tony Lindgren
2009-11-18 19:20 ` [PATCH 01/10] omap: mailbox: Add build specific changes to support omap mailbox Tony Lindgren
2009-11-18 19:20 ` [PATCH 02/10] omap: mailbox: Add resources and mailbox register base address for OMAP4 mailbox Tony Lindgren
2009-11-18 19:20 ` [PATCH 03/10] omap: mailbox: remove sequence bit checking Tony Lindgren
2009-11-18 19:20 ` [PATCH 04/10] omap: mailbox: remove class interface Tony Lindgren
2009-11-18 19:20 ` [PATCH 05/10] omap: mailbox: remove disable_/enable_mbox_irq in isr Tony Lindgren
2009-11-18 19:21 ` [PATCH 06/10] omap: mailbox: remove unnecessary arg for omap_mbox_msg_send Tony Lindgren
2009-11-18 19:21 ` [PATCH 07/10] omap: mailbox: Expose omap_mbox_enable()/disable_irq() Tony Lindgren
2009-11-18 19:21 ` [PATCH 08/10] omap: mailbox: Adds code changes to support OMAP4 mailbox Tony Lindgren
2009-11-18 19:21 ` [PATCH 09/10] omap: mailbox: OMAP4 Mailbox Patch to change the IRQ flag from IRQF_DISABLED to IRQF_SHARED Tony Lindgren
2009-11-18 19:21 ` [PATCH 10/10] omap: mailbox: OMAP4 Mailbox-driver Patch to support tasklet implementation Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2009-11-13 12:34 [PATCH 10/10] omap " C.A, Subramaniam
2009-09-04 11:48 C.A, Subramaniam
2009-09-07  8:49 ` Hiroshi DOYU
2009-09-08 17:43   ` C.A, Subramaniam
2009-09-09  9:02     ` Hiroshi DOYU
2009-09-09  9:14       ` C.A, Subramaniam
2009-09-10 11:46       ` C.A, Subramaniam
2009-09-10 12:28         ` Hiroshi DOYU
2009-09-14 11:35           ` C.A, Subramaniam
2009-09-14 12:43             ` 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).