OMAP: mailbox: fixes and enhancements
Subsystems (3)
v4 cover OMAP: mailbox: fixes and enhancements
Thanks to Benoit and Felipe Balbi for their comments.
Here is the revised set taking into account comments received.
========================
- Added more description for checkpatch warnings
- Created revision field to check for mailbox IP version to use for rx interrupt disable functionality.
- Cleaned up description in change full flag per mailbox patch.
References:
http://marc.info/?l=linux-omap&m=129012283514652&w=2
http://marc.info/?l=linux-omap&m=129016767426046&w=2
http://www.mail-archive.com/[email protected]/msg38826.html
The previous versions of this patch set can be found here
=======================
http://www.spinics.net/lists/arm-kernel/msg104544.html
http://www.spinics.net/lists/linux-omap/msg39988.html
http://www.spinics.net/lists/linux-omap/msg39931.html
http://www.mail-archive.com/[email protected]/msg37278.html
Fernando Guzman Lugo (1):
OMAP: mailbox: change full flag per mailbox queue instead of global
Hari Kanigeri (4):
OMAP: mailbox: fix rx interrupt disable in omap4
OMAP: mailbox: fix checkpatch warnings
OMAP: mailbox: send message in process context
OMAP: mailbox: add notification support for multiple readers
arch/arm/mach-omap2/mailbox.c | 7 ++- arch/arm/plat-omap/include/plat/mailbox.h | 12 ++- arch/arm/plat-omap/mailbox.c | 135 +++++++++++++++++------------ 3 files changed, 96 insertions(+), 58 deletions(-)
PATCH v4 1/5 OMAP: mailbox: change full flag per mailbox queue instead of global
From: Fernando Guzman Lugo <[email protected]>
The variable rq_full flag is a global variable, so if there are multiple mailbox users there will be conflicts. Now there is a full flag per mailbox queue.
--- arch/arm/plat-omap/include/plat/mailbox.h | 1 + arch/arm/plat-omap/mailbox.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +1 -0
@@ -48,6 +48,7 @@ struct omap_mbox_queue {struct tasklet_struct tasklet;int (*callback)(void *);struct omap_mbox *mbox; +bool full; };struct omap_mbox {
arch/arm/plat-omap/mailbox.c +7 -2
@@ -33,7 +33,6 @@static struct workqueue_struct *mboxd;static struct omap_mbox **mboxes; -static bool rq_full;static int mbox_configured;static DEFINE_MUTEX (mbox_configured_lock);
@@ -148,6 +147,12 @@ static void mbox_rx_work(struct work_struct *work)if (mq->callback) mq->callback ((void *)msg); +spin_lock_irq (&mq->lock); +if (mq->full) { + mq->full = false; +omap_mbox_enable_irq (mq->mbox,IRQ_RX ); + } +spin_unlock_irq (&mq->lock); } }
@@ -170,7 +175,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)while (!mbox_fifo_empty (mbox)) {if (unlikely (kfifo_avail (&mq->fifo) <sizeof (msg))) {omap_mbox_disable_irq (mbox,IRQ_RX ); - rq_full = true; + mq->full = true; goto nomem; }
Signature · 1 line
1.7.0
PATCH v4 1/5 OMAP: mailbox: change full flag per mailbox queue instead of global
Quoted 52 lines · Hari Kanigeri
From: Fernando Guzman Lugo <[email protected]>
The variable
rq_fullflag is a global variable, so if there are multiple mailbox users there will be conflicts. Now there is a full flag per mailbox queue.Reported-by Ohad Ben-Cohen <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>Signed-off-by Hari Kanigeri <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?1 + ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ? ?9 +++++++-- ?2 files changed, 8 insertions(+), 2 deletions(-)arch/arm/plat-omap/include/plat/mailbox.h +1
-0@@ -48,6 +48,7 @@ struct omap_mbox_queue { ? ? ? ?struct tasklet_struct ? tasklet; ? ? ? ?int ? ? (*callback)(void *); ? ? ? ?struct omap_mbox ? ? ? ?*mbox; + ? ? ? bool full; ?}; ?struct omap_mbox {arch/arm/plat-omap/mailbox.c +6
-1@@ -33,7 +33,6 @@ ?static struct workqueue_struct *mboxd; ?static struct omap_mbox **mboxes; -static bool rq_full; ?static int mbox_configured; ?static DEFINE_MUTEX(mbox_configured_lock);@@ -148,6 +147,12 @@ static void mbox_rx_work(struct work_struct *work) ? ? ? ? ? ? ? ?if (mq->callback) ? ? ? ? ? ? ? ? ? ? ? ?mq->callback((void *)msg); + ? ? ? ? ? ? ? spin_lock_irq(&mq->lock); + ? ? ? ? ? ? ? if (mq->full) { + ? ? ? ? ? ? ? ? ? ? ? mq->full = false; + ? ? ? ? ? ? ? ? ? ? ? omap_mbox_enable_irq(mq->mbox, IRQ_RX); + ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? spin_unlock_irq(&mq->lock); ? ? ? ?} ?}
arch/arm/plat-omap/mailbox.c static void __mbox_rx_interrupt(struct omap_mbox *mbox) · line 178
Quoted 5 lines
arch/arm/plat-omap/mailbox.c +1
-1@@ -170,7 +175,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) ? ? ? ?while (!mbox_fifo_empty(mbox)) { ? ? ? ? ? ? ? ?if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) { ? ? ? ? ? ? ? ? ? ? ? ?omap_mbox_disable_irq(mbox, IRQ_RX); - ? ? ? ? ? ? ? ? ? ? ? rq_full = true; + ? ? ? ? ? ? ? ? ? ? ? mq->full = true;
Should this also be inside spin_lock_irq?
Quoted 6 lines
arch/arm/plat-omap/mailbox.c +0
-1? ? ? ? ? ? ? ? ? ? ? ?goto nomem; ? ? ? ? ? ? ? ?} --1.7.0
PATCH v4 1/5 OMAP: mailbox: change full flag per mailbox queue instead of global
Quoted 52 lines · Charulatha
Quoted 51 lines · Hari Kanigeri
From: Fernando Guzman Lugo <[email protected]>
The variable
rq_fullflag is a global variable, so if there are multiple mailbox users there will be conflicts. Now there is a full flag per mailbox queue.Reported-by Ohad Ben-Cohen <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>Signed-off-by Hari Kanigeri <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?1 + ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ? ?9 +++++++-- ?2 files changed, 8 insertions(+), 2 deletions(-)arch/arm/plat-omap/include/plat/mailbox.h +1
-0@@ -48,6 +48,7 @@ struct omap_mbox_queue { ? ? ? ?struct tasklet_struct ? tasklet; ? ? ? ?int ? ? (*callback)(void *); ? ? ? ?struct omap_mbox ? ? ? ?*mbox; + ? ? ? bool full; ?}; ?struct omap_mbox {arch/arm/plat-omap/mailbox.c +6
-1@@ -33,7 +33,6 @@ ?static struct workqueue_struct *mboxd; ?static struct omap_mbox **mboxes; -static bool rq_full; ?static int mbox_configured; ?static DEFINE_MUTEX(mbox_configured_lock);@@ -148,6 +147,12 @@ static void mbox_rx_work(struct work_struct *work) ? ? ? ? ? ? ? ?if (mq->callback) ? ? ? ? ? ? ? ? ? ? ? ?mq->callback((void *)msg); + ? ? ? ? ? ? ? spin_lock_irq(&mq->lock); + ? ? ? ? ? ? ? if (mq->full) { + ? ? ? ? ? ? ? ? ? ? ? mq->full = false; + ? ? ? ? ? ? ? ? ? ? ? omap_mbox_enable_irq(mq->mbox, IRQ_RX); + ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? spin_unlock_irq(&mq->lock); ? ? ? ?} ?}
Quoted 9 lines
arch/arm/plat-omap/mailbox.c static void __mbox_rx_interrupt(struct omap_mbox *mbox) · line 178
Quoted 6 lines
arch/arm/plat-omap/mailbox.c +1
-1@@ -170,7 +175,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) ? ? ? ?while (!mbox_fifo_empty(mbox)) { ? ? ? ? ? ? ? ?if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) { ? ? ? ? ? ? ? ? ? ? ? ?omap_mbox_disable_irq(mbox, IRQ_RX); - ? ? ? ? ? ? ? ? ? ? ? rq_full = true; + ? ? ? ? ? ? ? ? ? ? ? mq->full = true;Should this also be inside
spin_lock_irq?
Not needed. this is already run from interrupt context.
Thank you,
Best regards,
Hari
PATCH v4 1/5 OMAP: mailbox: change full flag per mailbox queue instead of global
Quoted 63 lines · Hari
Quoted 52 lines · Charulatha
Quoted 51 lines · Hari Kanigeri
From: Fernando Guzman Lugo <[email protected]>
The variable
rq_fullflag is a global variable, so if there are multiple mailbox users there will be conflicts. Now there is a full flag per mailbox queue.Reported-by Ohad Ben-Cohen <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>Signed-off-by Hari Kanigeri <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?1 + ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ? ?9 +++++++-- ?2 files changed, 8 insertions(+), 2 deletions(-)arch/arm/plat-omap/include/plat/mailbox.h +1
-0@@ -48,6 +48,7 @@ struct omap_mbox_queue { ? ? ? ?struct tasklet_struct ? tasklet; ? ? ? ?int ? ? (*callback)(void *); ? ? ? ?struct omap_mbox ? ? ? ?*mbox; + ? ? ? bool full; ?}; ?struct omap_mbox {arch/arm/plat-omap/mailbox.c +6
-1@@ -33,7 +33,6 @@ ?static struct workqueue_struct *mboxd; ?static struct omap_mbox **mboxes; -static bool rq_full; ?static int mbox_configured; ?static DEFINE_MUTEX(mbox_configured_lock);@@ -148,6 +147,12 @@ static void mbox_rx_work(struct work_struct *work) ? ? ? ? ? ? ? ?if (mq->callback) ? ? ? ? ? ? ? ? ? ? ? ?mq->callback((void *)msg); + ? ? ? ? ? ? ? spin_lock_irq(&mq->lock); + ? ? ? ? ? ? ? if (mq->full) { + ? ? ? ? ? ? ? ? ? ? ? mq->full = false; + ? ? ? ? ? ? ? ? ? ? ? omap_mbox_enable_irq(mq->mbox, IRQ_RX); + ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? spin_unlock_irq(&mq->lock); ? ? ? ?} ?}Quoted 9 lines
arch/arm/plat-omap/mailbox.c static void __mbox_rx_interrupt(struct omap_mbox *mbox) · line 178
Quoted 6 lines
arch/arm/plat-omap/mailbox.c +1
-1@@ -170,7 +175,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) ? ? ? ?while (!mbox_fifo_empty(mbox)) { ? ? ? ? ? ? ? ?if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) { ? ? ? ? ? ? ? ? ? ? ? ?omap_mbox_disable_irq(mbox, IRQ_RX); - ? ? ? ? ? ? ? ? ? ? ? rq_full = true; + ? ? ? ? ? ? ? ? ? ? ? mq->full = true;Should this also be inside
spin_lock_irq?
Quoted 1 line
Not needed. this is already run from interrupt context.
oh ok.
Quoted 5 lines
Thank you,
Best regards,
Hari
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
In reply to Hari Kanigeridisablign rx interrupt on omap4 is different than its pre-decessors. The bit in OMAP4_MAILBOX_IRQENABLE_CLR should be set to disable the interrupts instead of clearing the bit.
Defined rev field in mailbox structure to differentiate the mailbox versions.
--- arch/arm/mach-omap2/mailbox.c | 7 ++++++- arch/arm/plat-omap/include/plat/mailbox.h | 4 ++++ arch/arm/plat-omap/mailbox.c | 4 ++++ 3 files changed, 14 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/mailbox.c +6 -1
@@ -195,7 +195,12 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv;u32 l, bit = (irq ==IRQ_TX ) ? p->notfull_bit : p->newmsg_bit; l =mbox_read_reg (p->irqdisable); - l &= ~bit; + +if (mbox->rev ==OMAP_MBOX_IP_VERSION_2 ) + l |= bit; +else + l &= ~bit; +mbox_write_reg (l, p->irqdisable); }
arch/arm/plat-omap/include/plat/mailbox.h +4 -0
@@ -20,6 +20,9 @@ typedef int __bitwise omap_mbox_type_t;#define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)#define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2) +#define OMAP_MBOX_IP_LEGACY 0x1 +#define OMAP_MBOX_IP_VERSION_2 0x2 +struct omap_mbox_ops {omap_mbox_type_t type;int (*startup)(struct omap_mbox *mbox);
@@ -58,6 +61,7 @@ struct omap_mbox {struct omap_mbox_ops *ops;struct device *dev;void *priv; +int rev; };int omap_mbox_msg_send (struct omap_mbox *,mbox_msg_t msg);
arch/arm/plat-omap/mailbox.c +4 -0
@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ret =PTR_ERR (mbox->dev); goto err_out; } +if (cpu_is_omap44xx ()) + mbox->rev =OMAP_MBOX_IP_VERSION_2 ; +else + mbox->rev =OMAP_MBOX_IP_LEGACY ; }return 0 ;
Signature · 1 line
1.7.0
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
On Wed, Nov 24, 2010 at 02:56, Hari Kanigeri <[email protected]> wrote:
Should the subject be like this?
OMAP4: mailbox: fix rx interrupt disable
Quoted 1 line
disablign rx interrupt on omap4 is different than its pre-decessors.
Typo ->disablign
Quoted 58 lines
The bit in
OMAP4_MAILBOX_IRQENABLE_CLRshould be set to disable the interrupts instead of clearing the bit.Defined rev field in mailbox structure to differentiate the mailbox versions.
Signed-off-by Hari Kanigeri <[email protected]>---
?arch/arm/mach-omap2/mailbox.c ? ? ? ? ? ? | ? ?7 ++++++- ?arch/arm/plat-omap/include/plat/mailbox.h | ? ?4 ++++ ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ? ?4 ++++?3 files changed, 14 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/mailbox.c +6
-1@@ -195,7 +195,12 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox, ? ? ? ?struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv; ? ? ? ?u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; ? ? ? ?l = mbox_read_reg(p->irqdisable); - ? ? ? l &= ~bit; + + ? ? ? if (mbox->rev == OMAP_MBOX_IP_VERSION_2) + ? ? ? ? ? ? ? l |= bit; + ? ? ? else + ? ? ? ? ? ? ? l &= ~bit; + ? ? ? ?mbox_write_reg(l, p->irqdisable); ?}arch/arm/plat-omap/include/plat/mailbox.h +4
-0@@ -20,6 +20,9 @@ typedef int __bitwise omap_mbox_type_t; ?#define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1) ?#define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2) +#define OMAP_MBOX_IP_LEGACY ? ? ? ? ? ? ? ? ? ?0x1 +#define OMAP_MBOX_IP_VERSION_2 ? ? ? ? ? ? ? ? 0x2 + ?struct omap_mbox_ops { ? ? ? ?omap_mbox_type_t ? ? ? ?type; ? ? ? ?int ? ? ? ? ? ? (*startup)(struct omap_mbox *mbox);@@ -58,6 +61,7 @@ struct omap_mbox { ? ? ? ?struct omap_mbox_ops ? ?*ops; ? ? ? ?struct device ? ? ? ? ? *dev; ? ? ? ?void ? ? ? ? ? ? ? ? ? ?*priv; + ? ? ? int ? ? ? ? ? ? ? ? ? ? rev; ?}; ?int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);arch/arm/plat-omap/mailbox.c +0
-0
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct omap_mbox **list) · line 361
Quoted 4 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())
Do not use cpu_is* checks in plat-omap/*
Quoted 9 lines
arch/arm/plat-omap/mailbox.c +3
-1+ ? ? ? ? ? ? ? ? ? ? ? mbox->rev = OMAP_MBOX_IP_VERSION_2; + ? ? ? ? ? ? ? else + ? ? ? ? ? ? ? ? ? ? ? mbox->rev = OMAP_MBOX_IP_LEGACY; ? ? ? ?} ? ? ? ?return 0; --1.7.0
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
Quoted 11 lines · Charulatha
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct omap_mbox **list) · line 361
Quoted 9 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())Do not use cpu_is* checks in plat-omap/*
see the previous thread.
Signature · 1 line
balbi
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
Quoted 15 lines · Felipe Balbi
Quoted 13 lines · Charulatha
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct · line 362
Quoted 11 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())Do not use cpu_is* checks in plat-omap/*
Quoted 1 line
see the previous thread.
Referring to [1], I do not find why cpu_is* checks is used in plat-omap and why it can't be avoided.
In [1], it was suggested to create the pdata field that will be populated at init
time using the cpu_is* check. But in this version, I am finding that this is done
in plat-omap. This can be handled in mach-omap layer itself and can be passed as a pdata field which can be extracted during probe.
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
Quoted 21 lines · Charulatha
Quoted 15 lines · Felipe Balbi
Quoted 13 lines · Charulatha
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct · line 362
Quoted 11 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())Do not use cpu_is* checks in plat-omap/*
Quoted 1 line
see the previous thread.
Referring to [1], I do not find why cpu_is* checks is used in plat-omap and why it can't be avoided.
Quoted 8 lines
In [1], it was suggested to create the pdata field that will be populated at init
time using the cpu_is* check. But in this version, I am finding that this is done
in plat-omap. This can be handled in mach-omap layer itself and can be passed as a pdata field which can be extracted during probe.
true, since I saw mbox->rev, I confused that with something that was coming from pdata, sorry. You're right, this is not the right way to do it.
Signature · 1 line
balbi
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
In reply to Varadarajan, CharulathaQuoted 21 lines · Charulatha
Quoted 15 lines · Felipe Balbi
Quoted 13 lines · Charulatha
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct · line 362
Quoted 11 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())Do not use cpu_is* checks in plat-omap/*
Quoted 1 line
see the previous thread.
Referring to [1], I do not find why cpu_is* checks is used in plat-omap and why it can't be avoided.
Quoted 9 lines
In [1], it was suggested to create the pdata field that will be populated at init
time using the cpu_is* check. But in this version, I am finding that this is done
in plat-omap. This can be handled in mach-omap layer itself and can be passed as a pdata field which can be extracted during probe.
Here are these reasons why I did this way.
- The function omap_mbox_register is called only once during probe time, and I thought it was ok to call cpu check once during probe time. Since each mbox instance needs to be aware of the rev field this was the right place to add since this function iterates through the list during probe time. There are already calls to cpu_is_omap44xx in mailbox probe function.
- platform data is not present for mailbox module. I could add it for revision sake but I would prefer not to do that since this will be a throw away code once the hwmod infrastructure is ready (note: mailbox hwmod patches are under review), and amount of mailbox driver rework might be considerable.
- I could wait till the hwmod patches are ready to include this change, but don't want to put the dependency with hwmod since this is a critical fix and want to make it available in the mainline kernel.
Please let me know what you suggest.
Thank you,
Best regards,
Hari Kanigeri
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
Hari,
Quoted 29 lines · Hari
Quoted 28 lines · Charulatha
Quoted 15 lines · Felipe Balbi
Quoted 13 lines · Charulatha
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct · line 362
Quoted 11 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())Do not use cpu_is* checks in plat-omap/*
Quoted 1 line
see the previous thread.
Referring to [1], I do not find why cpu_is* checks is used in plat-omap and why it can't be avoided.
In [1], it was suggested to create the pdata field that will be populated at init
time using the cpu_is* check. But in this version, I am finding that this is done
in plat-omap. This can be handled in mach-omap layer itself and can be passed as a pdata field which can be extracted during probe.
Quoted 8 lines
Quoted 2 lines
Here are these ?reasons why I did this way.
- The function
omap_mbox_registeris called only once during probe time, and I thought it was ok to call cpu check once during probe time.
AFAIK it is not okay. Patches are not accepted by maintainers if cpu_is* checks are newly added in plat-omap/*
Moreover, the plat-omap is for common code between omap1 and omap2+ If any specific info is required due to unavoidable reasons, they should be managed using pdata fld/ by some other means.
Quoted 4 lines
Since each mbox instance needs to be aware of the rev field this was the right place to add since this function iterates through the list during probe time. There are already calls to
cpu_is_omap44xxin mailbox probe function.
Infact , there are some more drivers like that. But some of them are getting cleaned up slowly (work under progress). But old code having cpu_is* checks does not justify adding a new cpu_is* check. As I mentioned, it is repeatedly being insisted in LO mailing list to avoid cpu_is* checks in plat-omap and to clean up the drivers to avoid these checks.
Quoted 6 lines
- platform data is not present for mailbox module. I could add it for revision sake but I would prefer not to do that since this will be a throw away code once the hwmod infrastructure is ready (note: mailbox hwmod patches are under review), and amount of mailbox driver rework might be considerable.
I would leave this to Tony/ Felipe/ Benoit to decide on this. If agreed, I don't see any issue. But there should be atleast a "TODO" mentioning that this needs to be cleaned up.
Quoted 11 lines
- I could wait till the hwmod patches are ready to include this change, but don't want to put the dependency with hwmod since this is a critical fix and want to make it available in the mainline kernel.
Please let me know what you suggest.
Thank you,
Best regards,
Hari Kanigeri
PATCH v4 2/5 OMAP: mailbox: fix rx interrupt disable in omap4
Quoted 65 lines · Charulatha
Hari,
Quoted 29 lines · Hari
Quoted 28 lines · Charulatha
Quoted 15 lines · Felipe Balbi
Quoted 13 lines · Charulatha
arch/arm/plat-omap/mailbox.c int omap_mbox_register(struct device *parent, struct · line 362
Quoted 11 lines
arch/arm/plat-omap/mailbox.c +1
-0@@ -358,6 +358,10 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? if (cpu_is_omap44xx())Do not use cpu_is* checks in plat-omap/*
Quoted 1 line
see the previous thread.
Referring to [1], I do not find why cpu_is* checks is used in plat-omap and why it can't be avoided.
In [1], it was suggested to create the pdata field that will be populated at init
time using the cpu_is* check. But in this version, I am finding that this is done
in plat-omap. This can be handled in mach-omap layer itself and can be passed as a pdata field which can be extracted during probe.Quoted 8 lines
Quoted 2 lines
Here are these ?reasons why I did this way.
- The function
omap_mbox_registeris called only once during probe time, and I thought it was ok to call cpu check once during probe time.AFAIK it is not okay. Patches are not accepted by maintainers if cpu_is* checks are newly added in plat-omap/*
Moreover, the plat-omap is for common code between omap1 and omap2+ If any specific info is required due to unavoidable reasons, they should be managed using pdata fld/ by some other means.Quoted 4 lines
Since each mbox instance needs to be aware of the rev field this was the right place to add since this function iterates through the list during probe time. There are already calls to
cpu_is_omap44xxin mailbox probe function.Infact , there are some more drivers like that. But some of them are getting cleaned up slowly (work under progress). But old code having cpu_is* checks does not justify adding a new cpu_is* check. As I mentioned, it is repeatedly being insisted in LO mailing list to avoid cpu_is* checks in plat-omap and to clean up the drivers to avoid these checks.
Quoted 6 lines
- platform data is not present for mailbox module. I could add it for revision sake but I would prefer not to do that since this will be a throw away code once the hwmod infrastructure is ready (note: mailbox hwmod patches are under review), and amount of mailbox driver rework might be considerable.
Quoted 4 lines
I would leave this to Tony/ Felipe/ Benoit to decide on this. If agreed, I don't see any issue. But there should be atleast a "TODO" mentioning that this needs to be cleaned up.
fair enough. I am dropping this patch from the patch set and will send it with Omar's hwmod patches.
I will send the revised patch set excluding this patch.
Thank you,
Best regards,
Hari
PATCH v4 3/5 OMAP: mailbox: fix checkpatch warnings
In reply to Hari KanigeriFix the following checkpatch warnings observed in mailbox module.
WARNING: please, no space for starting a line,
excluding comments
+ fail_alloc_rxq:$
WARNING: please, no space for starting a line,
excluding comments
+ fail_alloc_txq:$
WARNING: please, no space for starting a line,
excluding comments
+ fail_request_irq:$
WARNING: line over 80 characters
+ mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t));
--- arch/arm/plat-omap/mailbox.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/plat-omap/mailbox.c +5 -4
@@ -281,11 +281,11 @@ static int omap_mbox_startup(struct omap_mbox *mbox)return 0 ; - fail_alloc_rxq: +fail_alloc_rxq:mbox_queue_free (mbox->txq); - fail_alloc_txq: +fail_alloc_txq:free_irq (mbox->irq, mbox); - fail_request_irq: +fail_request_irq:if (mbox->ops->shutdown) mbox->ops->shutdown (mbox);
@@ -400,7 +400,8 @@ static int __init omap_mbox_init(void)/* kfifo size sanity check: alignment and minimal size */ mbox_kfifo_size =ALIGN (mbox_kfifo_size,sizeof (mbox_msg_t)); - mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t)); + mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, +sizeof (mbox_msg_t));return 0 ; }
Signature · 1 line
1.7.0
PATCH v4 4/5 OMAP: mailbox: send message in process context
In reply to Hari KanigeriSchedule the Tasklet to send only when mailbox fifo is full and there are pending messages in kifo, else send the message directly in the Process context. This would avoid needless scheduling of Tasklet for every message transfer
--- arch/arm/plat-omap/mailbox.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
arch/arm/plat-omap/mailbox.c +7 -2
@@ -92,20 +92,25 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)struct omap_mbox_queue *mq = mbox->txq;int ret =0 , len; -spin_lock (&mq->lock); +spin_lock_bh (&mq->lock);if (kfifo_avail (&mq->fifo) <sizeof (msg)) { ret = -ENOMEM ; goto out; } +if (kfifo_is_empty (&mq->fifo) && !__mbox_poll_for_space (mbox)) { +mbox_fifo_write (mbox, msg); + goto out; + } + len =kfifo_in (&mq->fifo, (unsigned char *)&msg,sizeof (msg));WARN_ON (len !=sizeof (msg));tasklet_schedule (&mbox->txq->tasklet); out: -spin_unlock (&mq->lock); +spin_unlock_bh (&mq->lock);return ret; }EXPORT_SYMBOL (omap_mbox_msg_send);
Signature · 1 line
1.7.0
PATCH v4 4/5 OMAP: mailbox: send message in process context
Quoted 2 lines · Hari Kanigeri
Schedule the Tasklet to send only when mailbox fifo is full and there are pending messages in kifo, else send the message directly in the Process
Typo -> kifo
Quoted 42 lines
context. This would avoid needless scheduling of Tasklet for every message transfer
Signed-off-by Hari Kanigeri <[email protected]>---
?arch/arm/plat-omap/mailbox.c | ? ?9 +++++++--
?1 files changed, 7 insertions(+), 2 deletions(-)arch/arm/plat-omap/mailbox.c +6
-1@@ -92,20 +92,25 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg) ? ? ? ?struct omap_mbox_queue *mq = mbox->txq; ? ? ? ?int ret = 0, len; - ? ? ? spin_lock(&mq->lock); + ? ? ? spin_lock_bh(&mq->lock); ? ? ? ?if (kfifo_avail(&mq->fifo) < sizeof(msg)) { ? ? ? ? ? ? ? ?ret = -ENOMEM; ? ? ? ? ? ? ? ?goto out; ? ? ? ?} + ? ? ? if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) { + ? ? ? ? ? ? ? mbox_fifo_write(mbox, msg); + ? ? ? ? ? ? ? goto out; + ? ? ? } + ? ? ? ?len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); ? ? ? ?WARN_ON(len != sizeof(msg)); ? ? ? ?tasklet_schedule(&mbox->txq->tasklet);?out:
- ? ? ?spin_unlock(&mq->lock);
+ ? ? ?spin_unlock_bh(&mq->lock);
? ? ? ?return ret;
?}
?EXPORT_SYMBOL(omap_mbox_msg_send);
--
1.7.0
PATCH v4 4/5 OMAP: mailbox: send message in process context
Quoted 5 lines · Charulatha
Quoted 2 lines · Hari Kanigeri
Schedule the Tasklet to send only when mailbox fifo is full and there are pending messages in kifo, else send the message directly in the Process
Typo -> kifo
Thanks :). My bad I I think overlooked Felipe's comment on my previous patch.
Thank you,
Best regards,
Hari Kanigeri
PATCH v4 5/5 OMAP: mailbox: add notification support for multiple readers
In reply to Hari KanigeriIn the current mailbox driver, the mailbox internal pointer for callback can be directly manipulated by the Users, so a second User can easily corrupt the first user's callback pointer. The initial effort to correct this issue can be referred here:
https://patchwork.kernel.org/patch/107520/
Along with fixing the above stated issue, this patch adds the flexibility option to register notifications from multiple readers to the events received on a mailbox instance. The discussion regarding this can be referred here.
http://www.mail-archive.com/[email protected]/msg30671.html
--- arch/arm/plat-omap/include/plat/mailbox.h | 7 +- arch/arm/plat-omap/mailbox.c | 104 ++++++++++++++++------------- 2 files changed, 62 insertions(+), 49 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +4 -3
@@ -49,7 +49,6 @@ struct omap_mbox_queue {struct kfifo fifo;struct work_struct work;struct tasklet_struct tasklet; -int (*callback)(void *);struct omap_mbox *mbox;bool full; };
@@ -62,13 +61,15 @@ struct omap_mbox {struct device *dev;void *priv;int rev; +int use_count; +struct blocking_notifier_head notifier; };int omap_mbox_msg_send (struct omap_mbox *,mbox_msg_t msg);void omap_mbox_init_seq (struct omap_mbox *); -struct omap_mbox *omap_mbox_get (const char *); -void omap_mbox_put (struct omap_mbox *); +struct omap_mbox *omap_mbox_get (const char *,struct notifier_block *nb); +void omap_mbox_put (struct omap_mbox *mbox,struct notifier_block *nb);int omap_mbox_register (struct device *parent,struct omap_mbox **);int omap_mbox_unregister (void );
arch/arm/plat-omap/mailbox.c +58 -46
164 lines not on this page · raw message
Signature · 1 line
1.7.0
PATCH v4 5/5 OMAP: mailbox: add notification support for multiple readers
Quoted 12 lines · Hari Kanigeri
In the current mailbox driver, the mailbox internal pointer for callback can be directly manipulated by the Users, so a second User can easily corrupt the first user's callback pointer. The initial effort to correct this issue can be referred here:
https://patchwork.kernel.org/patch/107520/Along with fixing the above stated issue, this patch ?adds the flexibility option to register notifications from
multiple readers to the events received on a mailbox instance. The discussion regarding this can be referred here.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg30671.html
Quoted 7 lines
Signed-off-by Hari Kanigeri <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?7 +- ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ?104 ++++++++++++++++------------- ?2 files changed, 62 insertions(+), 49 deletions(-)
<<snip>>
Review int omap_mbox_register(struct device *parent, struct omap_mbox **list) · line 375
Quoted 5 lines
(quoted diff) +1
-0@@ -363,10 +372,13 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} +
Do this change in the patch where the below code was added.
Quoted 12 lines
(quoted diff) +0
-0? ? ? ? ? ? ? ?if (cpu_is_omap44xx()) ? ? ? ? ? ? ? ? ? ? ? ?mbox->rev = OMAP_MBOX_IP_VERSION_2;? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ? ? ? ? ?mbox->rev =OMAP_MBOX_IP_LEGACY; +
+ ? ? ? ? ? ? ?BLOCKING_INIT_NOTIFIER_HEAD(&mbox->notifier); ? ? ? ?}
? ? ? ?return 0;--
1.7.0
PATCH v4 5/5 OMAP: mailbox: add notification support for multiple readers
Quoted 23 lines · Charulatha
Quoted 12 lines · Hari Kanigeri
In the current mailbox driver, the mailbox internal pointer for callback can be directly manipulated by the Users, so a second User can easily corrupt the first user's callback pointer. The initial effort to correct this issue can be referred here:
https://patchwork.kernel.org/patch/107520/Along with fixing the above stated issue, this patch ?adds the flexibility option to register notifications from
multiple readers to the events received on a mailbox instance. The discussion regarding this can be referred here.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg30671.htmlQuoted 7 lines
Signed-off-by Hari Kanigeri <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?7 +- ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ?104 ++++++++++++++++------------- ?2 files changed, 62 insertions(+), 49 deletions(-)<<snip>>
Quoted 7 lines
Review int omap_mbox_register(struct device *parent, struct omap_mbox **list) · line 375
Quoted 5 lines
(quoted diff) +1
-0@@ -363,10 +372,13 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} +Do this change in the patch where the below code was added.
I am sorry I didn't get you. you mean BLOCKING_INIT_NOTIFIER_HEAD line ? yes, it is needed for this patch.
Quoted 14 lines
Quoted 13 lines
(quoted diff) +0
-0? ? ? ? ? ? ? ?if (cpu_is_omap44xx()) ? ? ? ? ? ? ? ? ? ? ? ?mbox->rev = OMAP_MBOX_IP_VERSION_2;? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ? ? ? ? ?mbox->rev =OMAP_MBOX_IP_LEGACY; +
+ ? ? ? ? ? ? ?BLOCKING_INIT_NOTIFIER_HEAD(&mbox->notifier); ? ? ? ?}
? ? ? ?return 0;--
1.7.0
Signature · 3 lines
Thank you, Best regards, Hari Kanigeri
PATCH v4 5/5 OMAP: mailbox: add notification support for multiple readers
Quoted 32 lines · Hari
Quoted 23 lines · Charulatha
Quoted 12 lines · Hari Kanigeri
In the current mailbox driver, the mailbox internal pointer for callback can be directly manipulated by the Users, so a second User can easily corrupt the first user's callback pointer. The initial effort to correct this issue can be referred here:
https://patchwork.kernel.org/patch/107520/Along with fixing the above stated issue, this patch ?adds the flexibility option to register notifications from
multiple readers to the events received on a mailbox instance. The discussion regarding this can be referred here.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg30671.htmlQuoted 7 lines
Signed-off-by Hari Kanigeri <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?7 +- ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ?104 ++++++++++++++++------------- ?2 files changed, 62 insertions(+), 49 deletions(-)<<snip>>
Quoted 7 lines
Review int omap_mbox_register(struct device *parent, struct omap_mbox **list) · line 375
Quoted 5 lines
(quoted diff) +1
-0@@ -363,10 +372,13 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} +Do this change in the patch where the below code was added.
Quoted 2 lines
I am sorry I didn't get you. you mean
BLOCKING_INIT_NOTIFIER_HEADline ? yes, it is needed for this patch.
No. I was saying that adding a new line could be done in the patch where this piece of code (below 4 lines) was introduced. Sorry if that was not clear :-(
Quoted 22 lines
Quoted 10 lines
Quoted 10 lines
(quoted diff) +0
-0? ? ? ? ? ? ? ?if (cpu_is_omap44xx()) ? ? ? ? ? ? ? ? ? ? ? ?mbox->rev = OMAP_MBOX_IP_VERSION_2;? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ? ? ? ? ?mbox->rev =OMAP_MBOX_IP_LEGACY; +
+ ? ? ? ? ? ? ?BLOCKING_INIT_NOTIFIER_HEAD(&mbox->notifier); ? ? ? ?}
? ? ? ?return 0;Quoted 4 lines
Quoted 3 lines
--
1.7.0--
Thank you,
Best regards,
Hari Kanigeri
PATCH v4 5/5 OMAP: mailbox: add notification support for multiple readers
Quoted 33 lines · Charulatha
Quoted 32 lines · Hari
Quoted 30 lines · Charulatha
Quoted 12 lines · Hari Kanigeri
In the current mailbox driver, the mailbox internal pointer for callback can be directly manipulated by the Users, so a second User can easily corrupt the first user's callback pointer. The initial effort to correct this issue can be referred here:
https://patchwork.kernel.org/patch/107520/Along with fixing the above stated issue, this patch ?adds the flexibility option to register notifications from
multiple readers to the events received on a mailbox instance. The discussion regarding this can be referred here.
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg30671.htmlQuoted 7 lines
Signed-off-by Hari Kanigeri <[email protected]>Signed-off-by Fernando Guzman Lugo <[email protected]>---
?arch/arm/plat-omap/include/plat/mailbox.h | ? ?7 +- ?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ?104 ++++++++++++++++------------- ?2 files changed, 62 insertions(+), 49 deletions(-)<<snip>>
Review int omap_mbox_register(struct device *parent, struct omap_mbox **list) · line 375
Quoted 5 lines
(quoted diff) +1
-0@@ -363,10 +372,13 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list) ? ? ? ? ? ? ? ? ? ? ? ?ret = PTR_ERR(mbox->dev); ? ? ? ? ? ? ? ? ? ? ? ?goto err_out; ? ? ? ? ? ? ? ?} +Do this change in the patch where the below code was added.
Quoted 5 lines
Quoted 2 lines
I am sorry I didn't get you. you mean
BLOCKING_INIT_NOTIFIER_HEADline ? yes, it is needed for this patch.No. I was saying that adding a new line could be done in the patch where this piece of code (below 4 lines) was introduced. Sorry if that was not clear :-(
Got it. extra line can be removed.
Thank you,
Best regards,
Hari Kanigeri