All of lore.kernel.org
 help / color / mirror / Atom feed
From: CK Hu <ck.hu@mediatek.com>
To: Bibby Hsieh <bibby.hsieh@mediatek.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	<srv_heupstream@mediatek.com>,
	Nicolas Boichat <drinkcat@chromium.org>,
	Dennis-YC Hsieh <dennis-yc.hsieh@mediatek.com>,
	Houlong Wei <houlong.wei@mediatek.com>
Subject: Re: [PATCH 1/3] mailbox: mediatek: implement flush function
Date: Fri, 14 Feb 2020 13:53:10 +0800	[thread overview]
Message-ID: <1581659590.12440.4.camel@mtksdaap41> (raw)
In-Reply-To: <20200214043325.16618-2-bibby.hsieh@mediatek.com>

Hi, Bibby:

On Fri, 2020-02-14 at 12:33 +0800, Bibby Hsieh wrote:
> For client driver which need to reorganize the command buffer, it could
> use this function to flush the send command buffer.
> If the channel doesn't be started (usually in waiting for event), this
> function will abort it directly.
> 
> Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 50 ++++++++++++++++++++++++++++--
>  1 file changed, 48 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 9a6ce9f5a7db..03e58ff62007 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -5,6 +5,7 @@
>  #include <linux/bitops.h>
>  #include <linux/clk.h>
>  #include <linux/clk-provider.h>
> +#include <linux/completion.h>

Why add this?

>  #include <linux/dma-mapping.h>
>  #include <linux/errno.h>
>  #include <linux/interrupt.h>
> @@ -428,14 +429,59 @@ static int cmdq_mbox_startup(struct mbox_chan *chan)
>  	return 0;
>  }
>  
> -static void cmdq_mbox_shutdown(struct mbox_chan *chan)
> +static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
>  {
> +	struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv;
> +	struct cmdq_task_cb *cb;
> +	struct cmdq_cb_data data;
> +	struct cmdq *cmdq = dev_get_drvdata(chan->mbox->dev);
> +	struct cmdq_task *task, *tmp;
> +	unsigned long flags;
> +	u32 enable;
> +
> +	spin_lock_irqsave(&thread->chan->lock, flags);
> +	if (list_empty(&thread->task_busy_list))
> +		goto out;
> +
> +	WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0);
> +	if (!cmdq_thread_is_in_wfe(thread))
> +		goto wait;
> +
> +	list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
> +				 list_entry) {
> +		cb = &task->pkt->async_cb;
> +		list_del(&task->list_entry);
> +		kfree(task);
> +	}
> +
> +	if (cb->cb) {
> +		data.sta = -ENOBUFS;

CMDQ_CB_ERROR?

I do not like cmdq to define itself error code, use standard error code
is better.

> +		data.data = cb->data;
> +		cb->cb(data);
> +	}

Why just callback the latest packet? I think you should move this into
list_for_each_entry_safe{} loop.

> +
> +	cmdq_thread_resume(thread);
> +	cmdq_thread_disable(cmdq, thread);
> +	clk_disable(cmdq->clock);
> +
> +out:
> +	spin_unlock_irqrestore(&thread->chan->lock, flags);
> +	return 0;
> +
> +wait:
> +	cmdq_thread_resume(thread);
> +	spin_unlock_irqrestore(&thread->chan->lock, flags);
> +	if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_ENABLE_TASK,
> +				      enable, enable == 0, 1, timeout))
> +		dev_err(cmdq->mbox.dev, "Fail to wait GCE thread 0x%x done\n",
> +			(u32)(thread->base - cmdq->base));

I think you should return error when timeout.

> +	return 0;
>  }
>  
>  static const struct mbox_chan_ops cmdq_mbox_chan_ops = {
>  	.send_data = cmdq_mbox_send_data,
>  	.startup = cmdq_mbox_startup,
> -	.shutdown = cmdq_mbox_shutdown,

This patch is about flush function, why do you remove shutdown function?

Regards,
CK

> +	.flush = cmdq_mbox_flush,
>  };
>  
>  static struct mbox_chan *cmdq_xlate(struct mbox_controller *mbox,


WARNING: multiple messages have this Message-ID (diff)
From: CK Hu <ck.hu@mediatek.com>
To: Bibby Hsieh <bibby.hsieh@mediatek.com>
Cc: devicetree@vger.kernel.org,
	Nicolas Boichat <drinkcat@chromium.org>,
	srv_heupstream@mediatek.com,
	Jassi Brar <jassisinghbrar@gmail.com>,
	linux-kernel@vger.kernel.org,
	Houlong Wei <houlong.wei@mediatek.com>,
	Dennis-YC Hsieh <dennis-yc.hsieh@mediatek.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/3] mailbox: mediatek: implement flush function
Date: Fri, 14 Feb 2020 13:53:10 +0800	[thread overview]
Message-ID: <1581659590.12440.4.camel@mtksdaap41> (raw)
In-Reply-To: <20200214043325.16618-2-bibby.hsieh@mediatek.com>

Hi, Bibby:

On Fri, 2020-02-14 at 12:33 +0800, Bibby Hsieh wrote:
> For client driver which need to reorganize the command buffer, it could
> use this function to flush the send command buffer.
> If the channel doesn't be started (usually in waiting for event), this
> function will abort it directly.
> 
> Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 50 ++++++++++++++++++++++++++++--
>  1 file changed, 48 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 9a6ce9f5a7db..03e58ff62007 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -5,6 +5,7 @@
>  #include <linux/bitops.h>
>  #include <linux/clk.h>
>  #include <linux/clk-provider.h>
> +#include <linux/completion.h>

Why add this?

>  #include <linux/dma-mapping.h>
>  #include <linux/errno.h>
>  #include <linux/interrupt.h>
> @@ -428,14 +429,59 @@ static int cmdq_mbox_startup(struct mbox_chan *chan)
>  	return 0;
>  }
>  
> -static void cmdq_mbox_shutdown(struct mbox_chan *chan)
> +static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
>  {
> +	struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv;
> +	struct cmdq_task_cb *cb;
> +	struct cmdq_cb_data data;
> +	struct cmdq *cmdq = dev_get_drvdata(chan->mbox->dev);
> +	struct cmdq_task *task, *tmp;
> +	unsigned long flags;
> +	u32 enable;
> +
> +	spin_lock_irqsave(&thread->chan->lock, flags);
> +	if (list_empty(&thread->task_busy_list))
> +		goto out;
> +
> +	WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0);
> +	if (!cmdq_thread_is_in_wfe(thread))
> +		goto wait;
> +
> +	list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
> +				 list_entry) {
> +		cb = &task->pkt->async_cb;
> +		list_del(&task->list_entry);
> +		kfree(task);
> +	}
> +
> +	if (cb->cb) {
> +		data.sta = -ENOBUFS;

CMDQ_CB_ERROR?

I do not like cmdq to define itself error code, use standard error code
is better.

> +		data.data = cb->data;
> +		cb->cb(data);
> +	}

Why just callback the latest packet? I think you should move this into
list_for_each_entry_safe{} loop.

> +
> +	cmdq_thread_resume(thread);
> +	cmdq_thread_disable(cmdq, thread);
> +	clk_disable(cmdq->clock);
> +
> +out:
> +	spin_unlock_irqrestore(&thread->chan->lock, flags);
> +	return 0;
> +
> +wait:
> +	cmdq_thread_resume(thread);
> +	spin_unlock_irqrestore(&thread->chan->lock, flags);
> +	if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_ENABLE_TASK,
> +				      enable, enable == 0, 1, timeout))
> +		dev_err(cmdq->mbox.dev, "Fail to wait GCE thread 0x%x done\n",
> +			(u32)(thread->base - cmdq->base));

I think you should return error when timeout.

> +	return 0;
>  }
>  
>  static const struct mbox_chan_ops cmdq_mbox_chan_ops = {
>  	.send_data = cmdq_mbox_send_data,
>  	.startup = cmdq_mbox_startup,
> -	.shutdown = cmdq_mbox_shutdown,

This patch is about flush function, why do you remove shutdown function?

Regards,
CK

> +	.flush = cmdq_mbox_flush,
>  };
>  
>  static struct mbox_chan *cmdq_xlate(struct mbox_controller *mbox,

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: CK Hu <ck.hu@mediatek.com>
To: Bibby Hsieh <bibby.hsieh@mediatek.com>
Cc: devicetree@vger.kernel.org,
	Nicolas Boichat <drinkcat@chromium.org>,
	srv_heupstream@mediatek.com,
	Jassi Brar <jassisinghbrar@gmail.com>,
	linux-kernel@vger.kernel.org,
	Houlong Wei <houlong.wei@mediatek.com>,
	Dennis-YC Hsieh <dennis-yc.hsieh@mediatek.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/3] mailbox: mediatek: implement flush function
Date: Fri, 14 Feb 2020 13:53:10 +0800	[thread overview]
Message-ID: <1581659590.12440.4.camel@mtksdaap41> (raw)
In-Reply-To: <20200214043325.16618-2-bibby.hsieh@mediatek.com>

Hi, Bibby:

On Fri, 2020-02-14 at 12:33 +0800, Bibby Hsieh wrote:
> For client driver which need to reorganize the command buffer, it could
> use this function to flush the send command buffer.
> If the channel doesn't be started (usually in waiting for event), this
> function will abort it directly.
> 
> Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 50 ++++++++++++++++++++++++++++--
>  1 file changed, 48 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 9a6ce9f5a7db..03e58ff62007 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -5,6 +5,7 @@
>  #include <linux/bitops.h>
>  #include <linux/clk.h>
>  #include <linux/clk-provider.h>
> +#include <linux/completion.h>

Why add this?

>  #include <linux/dma-mapping.h>
>  #include <linux/errno.h>
>  #include <linux/interrupt.h>
> @@ -428,14 +429,59 @@ static int cmdq_mbox_startup(struct mbox_chan *chan)
>  	return 0;
>  }
>  
> -static void cmdq_mbox_shutdown(struct mbox_chan *chan)
> +static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
>  {
> +	struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv;
> +	struct cmdq_task_cb *cb;
> +	struct cmdq_cb_data data;
> +	struct cmdq *cmdq = dev_get_drvdata(chan->mbox->dev);
> +	struct cmdq_task *task, *tmp;
> +	unsigned long flags;
> +	u32 enable;
> +
> +	spin_lock_irqsave(&thread->chan->lock, flags);
> +	if (list_empty(&thread->task_busy_list))
> +		goto out;
> +
> +	WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0);
> +	if (!cmdq_thread_is_in_wfe(thread))
> +		goto wait;
> +
> +	list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
> +				 list_entry) {
> +		cb = &task->pkt->async_cb;
> +		list_del(&task->list_entry);
> +		kfree(task);
> +	}
> +
> +	if (cb->cb) {
> +		data.sta = -ENOBUFS;

CMDQ_CB_ERROR?

I do not like cmdq to define itself error code, use standard error code
is better.

> +		data.data = cb->data;
> +		cb->cb(data);
> +	}

Why just callback the latest packet? I think you should move this into
list_for_each_entry_safe{} loop.

> +
> +	cmdq_thread_resume(thread);
> +	cmdq_thread_disable(cmdq, thread);
> +	clk_disable(cmdq->clock);
> +
> +out:
> +	spin_unlock_irqrestore(&thread->chan->lock, flags);
> +	return 0;
> +
> +wait:
> +	cmdq_thread_resume(thread);
> +	spin_unlock_irqrestore(&thread->chan->lock, flags);
> +	if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_ENABLE_TASK,
> +				      enable, enable == 0, 1, timeout))
> +		dev_err(cmdq->mbox.dev, "Fail to wait GCE thread 0x%x done\n",
> +			(u32)(thread->base - cmdq->base));

I think you should return error when timeout.

> +	return 0;
>  }
>  
>  static const struct mbox_chan_ops cmdq_mbox_chan_ops = {
>  	.send_data = cmdq_mbox_send_data,
>  	.startup = cmdq_mbox_startup,
> -	.shutdown = cmdq_mbox_shutdown,

This patch is about flush function, why do you remove shutdown function?

Regards,
CK

> +	.flush = cmdq_mbox_flush,
>  };
>  
>  static struct mbox_chan *cmdq_xlate(struct mbox_controller *mbox,

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-02-14  5:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14  4:33 [PATCH 0/3] Remove atomic_exec Bibby Hsieh
2020-02-14  4:33 ` Bibby Hsieh
2020-02-14  4:33 ` Bibby Hsieh
2020-02-14  4:33 ` [PATCH 1/3] mailbox: mediatek: implement flush function Bibby Hsieh
2020-02-14  4:33   ` Bibby Hsieh
2020-02-14  4:33   ` Bibby Hsieh
2020-02-14  5:53   ` CK Hu [this message]
2020-02-14  5:53     ` CK Hu
2020-02-14  5:53     ` CK Hu
2020-02-14  4:33 ` [PATCH 2/3] mailbox: mediatek: remove implementation related to atomic_exec Bibby Hsieh
2020-02-14  4:33   ` Bibby Hsieh
2020-02-14  4:33   ` Bibby Hsieh
2020-02-14  5:54   ` CK Hu
2020-02-14  5:54     ` CK Hu
2020-02-14  5:54     ` CK Hu
2020-02-14  4:33 ` [PATCH 3/3] dt-binding: gce: remove atomic_exec in mboxes property Bibby Hsieh
2020-02-14  4:33   ` Bibby Hsieh
2020-02-14  4:33   ` Bibby Hsieh
2020-02-14  5:05   ` CK Hu
2020-02-14  5:05     ` CK Hu
2020-02-14  5:05     ` CK Hu
2020-02-14 10:30   ` Matthias Brugger
2020-02-14 10:30     ` Matthias Brugger
2020-02-14 10:30     ` Matthias Brugger

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=1581659590.12440.4.camel@mtksdaap41 \
    --to=ck.hu@mediatek.com \
    --cc=bibby.hsieh@mediatek.com \
    --cc=dennis-yc.hsieh@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@chromium.org \
    --cc=houlong.wei@mediatek.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=srv_heupstream@mediatek.com \
    /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: link
Be 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.