Loading drivers/soc/qcom/glink_smem_native_xprt.c +43 −13 Original line number Diff line number Diff line Loading @@ -213,6 +213,7 @@ struct edge_info { bool tx_blocked_signal_sent; struct kthread_work kwork; struct kthread_worker kworker; struct work_struct wakeup_work; struct task_struct *task; struct tasklet_struct tasklet; struct srcu_struct use_ref; Loading Loading @@ -874,20 +875,10 @@ static void __rx_worker(struct edge_info *einfo, bool atomic_ctx) srcu_read_unlock(&einfo->use_ref, rcu_id); return; } if (!atomic_ctx) { if (einfo->tx_resume_needed && fifo_write_avail(einfo)) { einfo->tx_resume_needed = false; einfo->xprt_if.glink_core_if_ptr->tx_resume( &einfo->xprt_if); } spin_lock_irqsave(&einfo->write_lock, flags); if (einfo->tx_blocked_signal_sent) { wake_up_all(&einfo->tx_blocked_queue); einfo->tx_blocked_signal_sent = false; } spin_unlock_irqrestore(&einfo->write_lock, flags); } if ((atomic_ctx) && ((einfo->tx_resume_needed) || (waitqueue_active(&einfo->tx_blocked_queue)))) /* tx waiting ?*/ schedule_work(&einfo->wakeup_work); /* * Access to the fifo needs to be synchronized, however only the calls Loading Loading @@ -1194,6 +1185,39 @@ static void rx_worker_atomic(unsigned long param) __rx_worker(einfo, true); } /** * tx_wakeup_worker() - worker function to wakeup tx blocked thread * @work: kwork associated with the edge to process commands on. */ static void tx_wakeup_worker(struct work_struct *work) { struct edge_info *einfo; bool trigger_wakeup = false; unsigned long flags; int rcu_id; einfo = container_of(work, struct edge_info, wakeup_work); rcu_id = srcu_read_lock(&einfo->use_ref); if (einfo->in_ssr) { srcu_read_unlock(&einfo->use_ref, rcu_id); return; } if (einfo->tx_resume_needed && fifo_write_avail(einfo)) { einfo->tx_resume_needed = false; einfo->xprt_if.glink_core_if_ptr->tx_resume( &einfo->xprt_if); } spin_lock_irqsave(&einfo->write_lock, flags); if (waitqueue_active(&einfo->tx_blocked_queue)) { /* tx waiting ?*/ einfo->tx_blocked_signal_sent = false; trigger_wakeup = true; } spin_unlock_irqrestore(&einfo->write_lock, flags); if (trigger_wakeup) wake_up_all(&einfo->tx_blocked_queue); srcu_read_unlock(&einfo->use_ref, rcu_id); } /** * rx_worker() - worker function to process received commands * @work: kwork associated with the edge to process commands on. Loading Loading @@ -2303,6 +2327,7 @@ static int glink_smem_native_probe(struct platform_device *pdev) init_waitqueue_head(&einfo->tx_blocked_queue); kthread_init_work(&einfo->kwork, rx_worker); kthread_init_worker(&einfo->kworker); INIT_WORK(&einfo->wakeup_work, tx_wakeup_worker); tasklet_init(&einfo->tasklet, rx_worker_atomic, (unsigned long)einfo); einfo->read_from_fifo = read_from_fifo; einfo->write_to_fifo = write_to_fifo; Loading Loading @@ -2402,6 +2427,7 @@ static int glink_smem_native_probe(struct platform_device *pdev) reg_xprt_fail: smem_alloc_fail: kthread_flush_worker(&einfo->kworker); flush_work(&einfo->wakeup_work); kthread_stop(einfo->task); einfo->task = NULL; tasklet_kill(&einfo->tasklet); Loading Loading @@ -2489,6 +2515,7 @@ static int glink_rpm_native_probe(struct platform_device *pdev) init_waitqueue_head(&einfo->tx_blocked_queue); kthread_init_work(&einfo->kwork, rx_worker); kthread_init_worker(&einfo->kworker); INIT_WORK(&einfo->wakeup_work, tx_wakeup_worker); tasklet_init(&einfo->tasklet, rx_worker_atomic, (unsigned long)einfo); einfo->intentless = true; einfo->read_from_fifo = memcpy32_fromio; Loading Loading @@ -2649,6 +2676,7 @@ static int glink_rpm_native_probe(struct platform_device *pdev) reg_xprt_fail: toc_init_fail: kthread_flush_worker(&einfo->kworker); flush_work(&einfo->wakeup_work); kthread_stop(einfo->task); einfo->task = NULL; tasklet_kill(&einfo->tasklet); Loading Loading @@ -2780,6 +2808,7 @@ static int glink_mailbox_probe(struct platform_device *pdev) init_waitqueue_head(&einfo->tx_blocked_queue); kthread_init_work(&einfo->kwork, rx_worker); kthread_init_worker(&einfo->kworker); INIT_WORK(&einfo->wakeup_work, tx_wakeup_worker); tasklet_init(&einfo->tasklet, rx_worker_atomic, (unsigned long)einfo); einfo->read_from_fifo = read_from_fifo; einfo->write_to_fifo = write_to_fifo; Loading Loading @@ -2900,6 +2929,7 @@ static int glink_mailbox_probe(struct platform_device *pdev) reg_xprt_fail: smem_alloc_fail: kthread_flush_worker(&einfo->kworker); flush_work(&einfo->wakeup_work); kthread_stop(einfo->task); einfo->task = NULL; tasklet_kill(&einfo->tasklet); Loading Loading
drivers/soc/qcom/glink_smem_native_xprt.c +43 −13 Original line number Diff line number Diff line Loading @@ -213,6 +213,7 @@ struct edge_info { bool tx_blocked_signal_sent; struct kthread_work kwork; struct kthread_worker kworker; struct work_struct wakeup_work; struct task_struct *task; struct tasklet_struct tasklet; struct srcu_struct use_ref; Loading Loading @@ -874,20 +875,10 @@ static void __rx_worker(struct edge_info *einfo, bool atomic_ctx) srcu_read_unlock(&einfo->use_ref, rcu_id); return; } if (!atomic_ctx) { if (einfo->tx_resume_needed && fifo_write_avail(einfo)) { einfo->tx_resume_needed = false; einfo->xprt_if.glink_core_if_ptr->tx_resume( &einfo->xprt_if); } spin_lock_irqsave(&einfo->write_lock, flags); if (einfo->tx_blocked_signal_sent) { wake_up_all(&einfo->tx_blocked_queue); einfo->tx_blocked_signal_sent = false; } spin_unlock_irqrestore(&einfo->write_lock, flags); } if ((atomic_ctx) && ((einfo->tx_resume_needed) || (waitqueue_active(&einfo->tx_blocked_queue)))) /* tx waiting ?*/ schedule_work(&einfo->wakeup_work); /* * Access to the fifo needs to be synchronized, however only the calls Loading Loading @@ -1194,6 +1185,39 @@ static void rx_worker_atomic(unsigned long param) __rx_worker(einfo, true); } /** * tx_wakeup_worker() - worker function to wakeup tx blocked thread * @work: kwork associated with the edge to process commands on. */ static void tx_wakeup_worker(struct work_struct *work) { struct edge_info *einfo; bool trigger_wakeup = false; unsigned long flags; int rcu_id; einfo = container_of(work, struct edge_info, wakeup_work); rcu_id = srcu_read_lock(&einfo->use_ref); if (einfo->in_ssr) { srcu_read_unlock(&einfo->use_ref, rcu_id); return; } if (einfo->tx_resume_needed && fifo_write_avail(einfo)) { einfo->tx_resume_needed = false; einfo->xprt_if.glink_core_if_ptr->tx_resume( &einfo->xprt_if); } spin_lock_irqsave(&einfo->write_lock, flags); if (waitqueue_active(&einfo->tx_blocked_queue)) { /* tx waiting ?*/ einfo->tx_blocked_signal_sent = false; trigger_wakeup = true; } spin_unlock_irqrestore(&einfo->write_lock, flags); if (trigger_wakeup) wake_up_all(&einfo->tx_blocked_queue); srcu_read_unlock(&einfo->use_ref, rcu_id); } /** * rx_worker() - worker function to process received commands * @work: kwork associated with the edge to process commands on. Loading Loading @@ -2303,6 +2327,7 @@ static int glink_smem_native_probe(struct platform_device *pdev) init_waitqueue_head(&einfo->tx_blocked_queue); kthread_init_work(&einfo->kwork, rx_worker); kthread_init_worker(&einfo->kworker); INIT_WORK(&einfo->wakeup_work, tx_wakeup_worker); tasklet_init(&einfo->tasklet, rx_worker_atomic, (unsigned long)einfo); einfo->read_from_fifo = read_from_fifo; einfo->write_to_fifo = write_to_fifo; Loading Loading @@ -2402,6 +2427,7 @@ static int glink_smem_native_probe(struct platform_device *pdev) reg_xprt_fail: smem_alloc_fail: kthread_flush_worker(&einfo->kworker); flush_work(&einfo->wakeup_work); kthread_stop(einfo->task); einfo->task = NULL; tasklet_kill(&einfo->tasklet); Loading Loading @@ -2489,6 +2515,7 @@ static int glink_rpm_native_probe(struct platform_device *pdev) init_waitqueue_head(&einfo->tx_blocked_queue); kthread_init_work(&einfo->kwork, rx_worker); kthread_init_worker(&einfo->kworker); INIT_WORK(&einfo->wakeup_work, tx_wakeup_worker); tasklet_init(&einfo->tasklet, rx_worker_atomic, (unsigned long)einfo); einfo->intentless = true; einfo->read_from_fifo = memcpy32_fromio; Loading Loading @@ -2649,6 +2676,7 @@ static int glink_rpm_native_probe(struct platform_device *pdev) reg_xprt_fail: toc_init_fail: kthread_flush_worker(&einfo->kworker); flush_work(&einfo->wakeup_work); kthread_stop(einfo->task); einfo->task = NULL; tasklet_kill(&einfo->tasklet); Loading Loading @@ -2780,6 +2808,7 @@ static int glink_mailbox_probe(struct platform_device *pdev) init_waitqueue_head(&einfo->tx_blocked_queue); kthread_init_work(&einfo->kwork, rx_worker); kthread_init_worker(&einfo->kworker); INIT_WORK(&einfo->wakeup_work, tx_wakeup_worker); tasklet_init(&einfo->tasklet, rx_worker_atomic, (unsigned long)einfo); einfo->read_from_fifo = read_from_fifo; einfo->write_to_fifo = write_to_fifo; Loading Loading @@ -2900,6 +2929,7 @@ static int glink_mailbox_probe(struct platform_device *pdev) reg_xprt_fail: smem_alloc_fail: kthread_flush_worker(&einfo->kworker); flush_work(&einfo->wakeup_work); kthread_stop(einfo->task); einfo->task = NULL; tasklet_kill(&einfo->tasklet); Loading