From: Tomi Valkeinen <tomi.valkeinen@nokia.com> To: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org Cc: Tomi Valkeinen <tomi.valkeinen@nokia.com> Subject: [PATCH 01/17] OMAP: DSS2: DSI: change DSI bus_lock to semaphore Date: Mon, 08 Feb 2010 15:57:25 +0000 [thread overview] Message-ID: <1265644661-3694-2-git-send-email-tomi.valkeinen@nokia.com> (raw) In-Reply-To: <1265644661-3694-1-git-send-email-tomi.valkeinen@nokia.com> Physical DSI bus is protected by a mutex. This patch changed the mutex to a semaphore, so that we can lock and unlock the bus_lock from different threads. This is needed as the update process is started by user space program, and thus the lock is acquired in that context, but the lock can be released in different context, a work thread via irq. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com> --- drivers/video/omap2/dss/dsi.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index 4b85ed2..74df72b 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c @@ -27,6 +27,7 @@ #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/mutex.h> +#include <linux/semaphore.h> #include <linux/seq_file.h> #include <linux/platform_device.h> #include <linux/regulator/consumer.h> @@ -227,7 +228,7 @@ static struct } vc[4]; struct mutex lock; - struct mutex bus_lock; + struct semaphore bus_lock; unsigned pll_locked; @@ -298,19 +299,19 @@ void dsi_restore_context(void) void dsi_bus_lock(void) { - mutex_lock(&dsi.bus_lock); + down(&dsi.bus_lock); } EXPORT_SYMBOL(dsi_bus_lock); void dsi_bus_unlock(void) { - mutex_unlock(&dsi.bus_lock); + up(&dsi.bus_lock); } EXPORT_SYMBOL(dsi_bus_unlock); static bool dsi_bus_is_locked(void) { - return mutex_is_locked(&dsi.bus_lock); + return dsi.bus_lock.count = 0; } static inline int wait_for_bit_change(const struct dsi_reg idx, int bitnum, @@ -3000,8 +3001,6 @@ static int dsi_update_thread(void *data) u16 x, y, w, h; while (1) { - bool sched; - wait_event_interruptible(dsi.waitqueue, dsi.update_mode = OMAP_DSS_UPDATE_AUTO || (dsi.update_mode = OMAP_DSS_UPDATE_MANUAL && @@ -3087,16 +3086,9 @@ static int dsi_update_thread(void *data) dsi_perf_show("L4"); } - sched = atomic_read(&dsi.bus_lock.count) < 0; - complete_all(&dsi.update_completion); dsi_bus_unlock(); - - /* XXX We need to give others chance to get the bus lock. Is - * there a better way for this? */ - if (dsi.update_mode = OMAP_DSS_UPDATE_AUTO && sched) - schedule_timeout_interruptible(1); } DSSDBG("update thread exiting\n"); @@ -3796,7 +3788,7 @@ int dsi_init(struct platform_device *pdev) spin_lock_init(&dsi.update_lock); mutex_init(&dsi.lock); - mutex_init(&dsi.bus_lock); + sema_init(&dsi.bus_lock, 1); #ifdef DSI_CATCH_MISSING_TE init_timer(&dsi.te_timer); -- 1.6.5
WARNING: multiple messages have this Message-ID (diff)
From: Tomi Valkeinen <tomi.valkeinen@nokia.com> To: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org Cc: Tomi Valkeinen <tomi.valkeinen@nokia.com> Subject: [PATCH 01/17] OMAP: DSS2: DSI: change DSI bus_lock to semaphore Date: Mon, 8 Feb 2010 17:57:25 +0200 [thread overview] Message-ID: <1265644661-3694-2-git-send-email-tomi.valkeinen@nokia.com> (raw) In-Reply-To: <1265644661-3694-1-git-send-email-tomi.valkeinen@nokia.com> Physical DSI bus is protected by a mutex. This patch changed the mutex to a semaphore, so that we can lock and unlock the bus_lock from different threads. This is needed as the update process is started by user space program, and thus the lock is acquired in that context, but the lock can be released in different context, a work thread via irq. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com> --- drivers/video/omap2/dss/dsi.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index 4b85ed2..74df72b 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c @@ -27,6 +27,7 @@ #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/mutex.h> +#include <linux/semaphore.h> #include <linux/seq_file.h> #include <linux/platform_device.h> #include <linux/regulator/consumer.h> @@ -227,7 +228,7 @@ static struct } vc[4]; struct mutex lock; - struct mutex bus_lock; + struct semaphore bus_lock; unsigned pll_locked; @@ -298,19 +299,19 @@ void dsi_restore_context(void) void dsi_bus_lock(void) { - mutex_lock(&dsi.bus_lock); + down(&dsi.bus_lock); } EXPORT_SYMBOL(dsi_bus_lock); void dsi_bus_unlock(void) { - mutex_unlock(&dsi.bus_lock); + up(&dsi.bus_lock); } EXPORT_SYMBOL(dsi_bus_unlock); static bool dsi_bus_is_locked(void) { - return mutex_is_locked(&dsi.bus_lock); + return dsi.bus_lock.count == 0; } static inline int wait_for_bit_change(const struct dsi_reg idx, int bitnum, @@ -3000,8 +3001,6 @@ static int dsi_update_thread(void *data) u16 x, y, w, h; while (1) { - bool sched; - wait_event_interruptible(dsi.waitqueue, dsi.update_mode == OMAP_DSS_UPDATE_AUTO || (dsi.update_mode == OMAP_DSS_UPDATE_MANUAL && @@ -3087,16 +3086,9 @@ static int dsi_update_thread(void *data) dsi_perf_show("L4"); } - sched = atomic_read(&dsi.bus_lock.count) < 0; - complete_all(&dsi.update_completion); dsi_bus_unlock(); - - /* XXX We need to give others chance to get the bus lock. Is - * there a better way for this? */ - if (dsi.update_mode == OMAP_DSS_UPDATE_AUTO && sched) - schedule_timeout_interruptible(1); } DSSDBG("update thread exiting\n"); @@ -3796,7 +3788,7 @@ int dsi_init(struct platform_device *pdev) spin_lock_init(&dsi.update_lock); mutex_init(&dsi.lock); - mutex_init(&dsi.bus_lock); + sema_init(&dsi.bus_lock, 1); #ifdef DSI_CATCH_MISSING_TE init_timer(&dsi.te_timer); -- 1.6.5
next prev parent reply other threads:[~2010-02-08 15:57 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-02-08 15:57 [PATCH 00/17] OMAP DSS2 model restructuring Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen [this message] 2010-02-08 15:57 ` [PATCH 01/17] OMAP: DSS2: DSI: change DSI bus_lock to semaphore Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 02/17] OMAP: DSS2: DSI: remove auto-update perf measurement Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 03/17] OMAP: DSS2: move run_test() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 04/17] OMAP: DSS2: move memory_read() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 05/17] OMAP: DSS2: move set/get_mirror() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 06/17] OMAP: DSS2: move get/set_rotate() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 07/17] OMAP: DSS2: move wait_vsync() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 08/17] OMAP: DSS2: move enable/disable_channel to overlay manager Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 09/17] OMAP: DSS2: move get_resolution() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 10/17] OMAP: DSS2: move get_recommended_bpp() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 11/17] OMAP: DSS2: move enable/get_te() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 12/17] OMAP: DSS2: move set/get_update_mode() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 13/17] OMAP: DSS2: move update() and sync() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 14/17] OMAP: DSS2: move enable/disable/suspend/resume Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 15/17] OMAP: DSS2: move set/get_wss() Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 16/17] OMAP: DSS2: move timing functions Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-08 15:57 ` [PATCH 17/17] OMAP: DSS2: DSI: Add VC support for update Tomi Valkeinen 2010-02-08 15:57 ` Tomi Valkeinen 2010-02-09 10:15 ` [PATCH 14/17] OMAP: DSS2: move enable/disable/suspend/resume Grazvydas Ignotas 2010-02-09 10:15 ` Grazvydas Ignotas 2010-02-09 12:12 ` Tomi Valkeinen 2010-02-09 12:12 ` Tomi Valkeinen 2010-02-13 15:34 ` [PATCH 00/17] OMAP DSS2 model restructuring Grazvydas Ignotas 2010-02-13 15:34 ` Grazvydas Ignotas 2010-02-15 7:45 ` Tomi Valkeinen 2010-02-15 7:45 ` Tomi Valkeinen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1265644661-3694-2-git-send-email-tomi.valkeinen@nokia.com \ --to=tomi.valkeinen@nokia.com \ --cc=linux-fbdev@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.