diff mbox series

[2/3] mailbox: mtk-cmdq: Use mailbox rx_callback

Message ID 20210314233323.23377-3-chunkuang.hu@kernel.org (mailing list archive)
State New, archived
Headers show
Series Refine mtk-cmdq-mailbox callback mechanism | expand

Commit Message

Chun-Kuang Hu March 14, 2021, 11:33 p.m. UTC
rx_callback is a standard mailbox callback mechanism and could cover the
function of proprietary cmdq_task_cb, so use the standard one instead of
the proprietary one. But the client driver has already used cmdq_task_cb,
so keep cmdq_task_cb until all client driver use rx_callback instead of
cmdq_task_cb.

Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Houlong Wei <houlong.wei@mediatek.com>
Cc: Bibby Hsieh <bibby.hsieh@mediatek.com>
Cc: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Chun-Kuang Hu May 26, 2021, 6:17 a.m. UTC | #1
+ Yongqiang

Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2021年3月15日 週一 上午7:33寫道:
>
> rx_callback is a standard mailbox callback mechanism and could cover the
> function of proprietary cmdq_task_cb, so use the standard one instead of
> the proprietary one. But the client driver has already used cmdq_task_cb,
> so keep cmdq_task_cb until all client driver use rx_callback instead of
> cmdq_task_cb.
>
> Cc: Jassi Brar <jassisinghbrar@gmail.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: Houlong Wei <houlong.wei@mediatek.com>
> Cc: Bibby Hsieh <bibby.hsieh@mediatek.com>
> Cc: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 3d37c1cd40f1..ef59e2234f22 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -188,7 +188,10 @@ static void cmdq_task_exec_done(struct cmdq_task *task, int sta)
>         WARN_ON(cb->cb == (cmdq_async_flush_cb)NULL);
>         data.sta = sta;
>         data.data = cb->data;
> -       cb->cb(data);
> +       if (cb->cb)
> +               cb->cb(data);
> +
> +       mbox_chan_received_data(task->thread->chan, &data);
>
>         list_del(&task->list_entry);
>  }
> @@ -451,12 +454,13 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
>
>         list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
>                                  list_entry) {
> +               data.sta = -ECONNABORTED;
> +               data.data = cb->data;
>                 cb = &task->pkt->async_cb;
> -               if (cb->cb) {
> -                       data.sta = -ECONNABORTED;
> -                       data.data = cb->data;
> +               if (cb->cb)
>                         cb->cb(data);
> -               }
> +
> +               mbox_chan_received_data(task->thread->chan, &data);
>                 list_del(&task->list_entry);
>                 kfree(task);
>         }
> --
> 2.17.1
>
Yongqiang Niu May 26, 2021, 6:51 a.m. UTC | #2
Reviewed-by: Yongqiang Niu <yongqiang.niu@mediatek.com>

On Wed, 2021-05-26 at 14:17 +0800, Chun-Kuang Hu wrote:
> + Yongqiang
> 
> Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2021年3月15日 週一 上午7:33寫道:
> >
> > rx_callback is a standard mailbox callback mechanism and could cover the
> > function of proprietary cmdq_task_cb, so use the standard one instead of
> > the proprietary one. But the client driver has already used cmdq_task_cb,
> > so keep cmdq_task_cb until all client driver use rx_callback instead of
> > cmdq_task_cb.
> >
> > Cc: Jassi Brar <jassisinghbrar@gmail.com>
> > Cc: Matthias Brugger <matthias.bgg@gmail.com>
> > Cc: Houlong Wei <houlong.wei@mediatek.com>
> > Cc: Bibby Hsieh <bibby.hsieh@mediatek.com>
> > Cc: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-arm-kernel@lists.infradead.org
> > Cc: linux-mediatek@lists.infradead.org
> > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > ---
> >  drivers/mailbox/mtk-cmdq-mailbox.c | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> > index 3d37c1cd40f1..ef59e2234f22 100644
> > --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> > +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> > @@ -188,7 +188,10 @@ static void cmdq_task_exec_done(struct cmdq_task *task, int sta)
> >         WARN_ON(cb->cb == (cmdq_async_flush_cb)NULL);
> >         data.sta = sta;
> >         data.data = cb->data;
> > -       cb->cb(data);
> > +       if (cb->cb)
> > +               cb->cb(data);
> > +
> > +       mbox_chan_received_data(task->thread->chan, &data);
> >
> >         list_del(&task->list_entry);
> >  }
> > @@ -451,12 +454,13 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
> >
> >         list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
> >                                  list_entry) {
> > +               data.sta = -ECONNABORTED;
> > +               data.data = cb->data;
> >                 cb = &task->pkt->async_cb;
> > -               if (cb->cb) {
> > -                       data.sta = -ECONNABORTED;
> > -                       data.data = cb->data;
> > +               if (cb->cb)
> >                         cb->cb(data);
> > -               }
> > +
> > +               mbox_chan_received_data(task->thread->chan, &data);
> >                 list_del(&task->list_entry);
> >                 kfree(task);
> >         }
> > --
> > 2.17.1
> >
diff mbox series

Patch

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 3d37c1cd40f1..ef59e2234f22 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -188,7 +188,10 @@  static void cmdq_task_exec_done(struct cmdq_task *task, int sta)
 	WARN_ON(cb->cb == (cmdq_async_flush_cb)NULL);
 	data.sta = sta;
 	data.data = cb->data;
-	cb->cb(data);
+	if (cb->cb)
+		cb->cb(data);
+
+	mbox_chan_received_data(task->thread->chan, &data);
 
 	list_del(&task->list_entry);
 }
@@ -451,12 +454,13 @@  static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
 
 	list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
 				 list_entry) {
+		data.sta = -ECONNABORTED;
+		data.data = cb->data;
 		cb = &task->pkt->async_cb;
-		if (cb->cb) {
-			data.sta = -ECONNABORTED;
-			data.data = cb->data;
+		if (cb->cb)
 			cb->cb(data);
-		}
+
+		mbox_chan_received_data(task->thread->chan, &data);
 		list_del(&task->list_entry);
 		kfree(task);
 	}