Loading arch/arm/mach-msm/smd_pkt.c +22 −19 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ #include <linux/msm_smd_pkt.h> #include <linux/poll.h> #include <asm/ioctls.h> #include <linux/wakelock.h> #include <linux/pm.h> #include <linux/of.h> #include <linux/ipc_logging.h> Loading @@ -47,7 +47,7 @@ #define MODULE_NAME "msm_smdpkt" #define DEVICE_NAME "smdpkt" #define WAKELOCK_TIMEOUT (2*HZ) #define WAKEUPSOURCE_TIMEOUT (2000) /* two seconds */ struct smd_pkt_dev { struct list_head dev_list; Loading Loading @@ -79,10 +79,10 @@ struct smd_pkt_dev { int has_reset; int do_reset_notification; struct completion ch_allocated; struct wake_lock pa_wake_lock; /* Packet Arrival Wake lock*/ struct wakeup_source pa_ws; /* Packet Arrival Wakeup Source */ struct work_struct packet_arrival_work; struct spinlock pa_spinlock; int wakelock_locked; int ws_locked; }; Loading Loading @@ -375,11 +375,14 @@ static void packet_arrival_worker(struct work_struct *work) packet_arrival_work); mutex_lock(&smd_pkt_devp->ch_lock); spin_lock_irqsave(&smd_pkt_devp->pa_spinlock, flags); if (smd_pkt_devp->ch && smd_pkt_devp->wakelock_locked) { D_READ("%s locking smd_pkt_dev id:%d wakelock\n", if (smd_pkt_devp->ch && smd_pkt_devp->ws_locked) { D_READ("%s locking smd_pkt_dev id:%d wakeup source\n", __func__, smd_pkt_devp->i); wake_lock_timeout(&smd_pkt_devp->pa_wake_lock, WAKELOCK_TIMEOUT); /* * Keep system awake long enough to allow userspace client * to process the packet. */ __pm_wakeup_event(&smd_pkt_devp->pa_ws, WAKEUPSOURCE_TIMEOUT); } spin_unlock_irqrestore(&smd_pkt_devp->pa_spinlock, flags); mutex_unlock(&smd_pkt_devp->ch_lock); Loading Loading @@ -540,10 +543,10 @@ wait_for_packet: spin_lock_irqsave(&smd_pkt_devp->pa_spinlock, flags); if (smd_pkt_devp->poll_mode && !smd_cur_packet_size(smd_pkt_devp->ch)) { wake_unlock(&smd_pkt_devp->pa_wake_lock); smd_pkt_devp->wakelock_locked = 0; __pm_relax(&smd_pkt_devp->pa_ws); smd_pkt_devp->ws_locked = 0; smd_pkt_devp->poll_mode = 0; D_READ("%s unlocked smd_pkt_dev id:%d wakelock\n", D_READ("%s unlocked smd_pkt_dev id:%d wakeup_source\n", __func__, smd_pkt_devp->i); } spin_unlock_irqrestore(&smd_pkt_devp->pa_spinlock, flags); Loading Loading @@ -709,8 +712,8 @@ static void check_and_wakeup_reader(struct smd_pkt_dev *smd_pkt_devp) /* here we have a packet of size sz ready */ spin_lock_irqsave(&smd_pkt_devp->pa_spinlock, flags); wake_lock(&smd_pkt_devp->pa_wake_lock); smd_pkt_devp->wakelock_locked = 1; __pm_stay_awake(&smd_pkt_devp->pa_ws); smd_pkt_devp->ws_locked = 1; spin_unlock_irqrestore(&smd_pkt_devp->pa_spinlock, flags); wake_up(&smd_pkt_devp->ch_read_wait_queue); schedule_work(&smd_pkt_devp->packet_arrival_work); Loading Loading @@ -1065,7 +1068,7 @@ int smd_pkt_open(struct inode *inode, struct file *file) mutex_lock(&smd_pkt_devp->ch_lock); if (smd_pkt_devp->ch == 0) { wake_lock_init(&smd_pkt_devp->pa_wake_lock, WAKE_LOCK_SUSPEND, wakeup_source_init(&smd_pkt_devp->pa_ws, smd_pkt_devp->dev_name); INIT_WORK(&smd_pkt_devp->packet_arrival_work, packet_arrival_worker); Loading Loading @@ -1175,7 +1178,7 @@ release_pd: smd_pkt_remove_driver(smd_pkt_devp); out: if (!smd_pkt_devp->ch) wake_lock_destroy(&smd_pkt_devp->pa_wake_lock); wakeup_source_trash(&smd_pkt_devp->pa_ws); mutex_unlock(&smd_pkt_devp->ch_lock); Loading Loading @@ -1212,8 +1215,8 @@ int smd_pkt_release(struct inode *inode, struct file *file) subsystem_put(smd_pkt_devp->pil); smd_pkt_devp->has_reset = 0; smd_pkt_devp->do_reset_notification = 0; smd_pkt_devp->wakelock_locked = 0; wake_lock_destroy(&smd_pkt_devp->pa_wake_lock); smd_pkt_devp->ws_locked = 0; wakeup_source_trash(&smd_pkt_devp->pa_ws); } mutex_unlock(&smd_pkt_devp->tx_lock); mutex_unlock(&smd_pkt_devp->rx_lock); Loading Loading @@ -1245,7 +1248,7 @@ static int smd_pkt_init_add_device(struct smd_pkt_dev *smd_pkt_devp, int i) init_waitqueue_head(&smd_pkt_devp->ch_write_wait_queue); smd_pkt_devp->is_open = 0; smd_pkt_devp->poll_mode = 0; smd_pkt_devp->wakelock_locked = 0; smd_pkt_devp->ws_locked = 0; init_waitqueue_head(&smd_pkt_devp->ch_opened_wait_queue); spin_lock_init(&smd_pkt_devp->pa_spinlock); Loading Loading
arch/arm/mach-msm/smd_pkt.c +22 −19 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ #include <linux/msm_smd_pkt.h> #include <linux/poll.h> #include <asm/ioctls.h> #include <linux/wakelock.h> #include <linux/pm.h> #include <linux/of.h> #include <linux/ipc_logging.h> Loading @@ -47,7 +47,7 @@ #define MODULE_NAME "msm_smdpkt" #define DEVICE_NAME "smdpkt" #define WAKELOCK_TIMEOUT (2*HZ) #define WAKEUPSOURCE_TIMEOUT (2000) /* two seconds */ struct smd_pkt_dev { struct list_head dev_list; Loading Loading @@ -79,10 +79,10 @@ struct smd_pkt_dev { int has_reset; int do_reset_notification; struct completion ch_allocated; struct wake_lock pa_wake_lock; /* Packet Arrival Wake lock*/ struct wakeup_source pa_ws; /* Packet Arrival Wakeup Source */ struct work_struct packet_arrival_work; struct spinlock pa_spinlock; int wakelock_locked; int ws_locked; }; Loading Loading @@ -375,11 +375,14 @@ static void packet_arrival_worker(struct work_struct *work) packet_arrival_work); mutex_lock(&smd_pkt_devp->ch_lock); spin_lock_irqsave(&smd_pkt_devp->pa_spinlock, flags); if (smd_pkt_devp->ch && smd_pkt_devp->wakelock_locked) { D_READ("%s locking smd_pkt_dev id:%d wakelock\n", if (smd_pkt_devp->ch && smd_pkt_devp->ws_locked) { D_READ("%s locking smd_pkt_dev id:%d wakeup source\n", __func__, smd_pkt_devp->i); wake_lock_timeout(&smd_pkt_devp->pa_wake_lock, WAKELOCK_TIMEOUT); /* * Keep system awake long enough to allow userspace client * to process the packet. */ __pm_wakeup_event(&smd_pkt_devp->pa_ws, WAKEUPSOURCE_TIMEOUT); } spin_unlock_irqrestore(&smd_pkt_devp->pa_spinlock, flags); mutex_unlock(&smd_pkt_devp->ch_lock); Loading Loading @@ -540,10 +543,10 @@ wait_for_packet: spin_lock_irqsave(&smd_pkt_devp->pa_spinlock, flags); if (smd_pkt_devp->poll_mode && !smd_cur_packet_size(smd_pkt_devp->ch)) { wake_unlock(&smd_pkt_devp->pa_wake_lock); smd_pkt_devp->wakelock_locked = 0; __pm_relax(&smd_pkt_devp->pa_ws); smd_pkt_devp->ws_locked = 0; smd_pkt_devp->poll_mode = 0; D_READ("%s unlocked smd_pkt_dev id:%d wakelock\n", D_READ("%s unlocked smd_pkt_dev id:%d wakeup_source\n", __func__, smd_pkt_devp->i); } spin_unlock_irqrestore(&smd_pkt_devp->pa_spinlock, flags); Loading Loading @@ -709,8 +712,8 @@ static void check_and_wakeup_reader(struct smd_pkt_dev *smd_pkt_devp) /* here we have a packet of size sz ready */ spin_lock_irqsave(&smd_pkt_devp->pa_spinlock, flags); wake_lock(&smd_pkt_devp->pa_wake_lock); smd_pkt_devp->wakelock_locked = 1; __pm_stay_awake(&smd_pkt_devp->pa_ws); smd_pkt_devp->ws_locked = 1; spin_unlock_irqrestore(&smd_pkt_devp->pa_spinlock, flags); wake_up(&smd_pkt_devp->ch_read_wait_queue); schedule_work(&smd_pkt_devp->packet_arrival_work); Loading Loading @@ -1065,7 +1068,7 @@ int smd_pkt_open(struct inode *inode, struct file *file) mutex_lock(&smd_pkt_devp->ch_lock); if (smd_pkt_devp->ch == 0) { wake_lock_init(&smd_pkt_devp->pa_wake_lock, WAKE_LOCK_SUSPEND, wakeup_source_init(&smd_pkt_devp->pa_ws, smd_pkt_devp->dev_name); INIT_WORK(&smd_pkt_devp->packet_arrival_work, packet_arrival_worker); Loading Loading @@ -1175,7 +1178,7 @@ release_pd: smd_pkt_remove_driver(smd_pkt_devp); out: if (!smd_pkt_devp->ch) wake_lock_destroy(&smd_pkt_devp->pa_wake_lock); wakeup_source_trash(&smd_pkt_devp->pa_ws); mutex_unlock(&smd_pkt_devp->ch_lock); Loading Loading @@ -1212,8 +1215,8 @@ int smd_pkt_release(struct inode *inode, struct file *file) subsystem_put(smd_pkt_devp->pil); smd_pkt_devp->has_reset = 0; smd_pkt_devp->do_reset_notification = 0; smd_pkt_devp->wakelock_locked = 0; wake_lock_destroy(&smd_pkt_devp->pa_wake_lock); smd_pkt_devp->ws_locked = 0; wakeup_source_trash(&smd_pkt_devp->pa_ws); } mutex_unlock(&smd_pkt_devp->tx_lock); mutex_unlock(&smd_pkt_devp->rx_lock); Loading Loading @@ -1245,7 +1248,7 @@ static int smd_pkt_init_add_device(struct smd_pkt_dev *smd_pkt_devp, int i) init_waitqueue_head(&smd_pkt_devp->ch_write_wait_queue); smd_pkt_devp->is_open = 0; smd_pkt_devp->poll_mode = 0; smd_pkt_devp->wakelock_locked = 0; smd_pkt_devp->ws_locked = 0; init_waitqueue_head(&smd_pkt_devp->ch_opened_wait_queue); spin_lock_init(&smd_pkt_devp->pa_spinlock); Loading