devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: CK Hu <ck.hu@mediatek.com>
To: houlong wei <houlong.wei@mediatek.com>
Cc: "Jassi Brar" <jassisinghbrar@gmail.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Daniel Kurtz" <djkurtz@chromium.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	srv_heupstream <srv_heupstream@mediatek.com>,
	"Sascha Hauer" <kernel@pengutronix.de>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Nicolas Boichat" <drinkcat@chromium.org>,
	"Cawa Cheng (鄭曄禧)" <cawa.cheng@mediatek.com>
Subject: Re: [PATCH v21 2/4] mailbox: mediatek: Add Mediatek CMDQ driver
Date: Thu, 28 Jun 2018 09:57:39 +0800	[thread overview]
Message-ID: <1530151059.6193.27.camel@mtksdaap41> (raw)
In-Reply-To: <1530100416.31725.15.camel@mhfsdcap03>

Hi, Houlong:

On Wed, 2018-06-27 at 19:53 +0800, houlong wei wrote:
> On Wed, 2018-02-21 at 11:53 +0800, CK Hu wrote:
> > Hi, Houlong:
> > 
> > I've one inline comment.
> > 
> > On Wed, 2018-01-31 at 15:28 +0800, houlong.wei@mediatek.com wrote:
> > > From: "hs.liao@mediatek.com" <hs.liao@mediatek.com>
> > > 
> > > This patch is first version of Mediatek Command Queue(CMDQ) driver. The
> > > CMDQ is used to help write registers with critical time limitation,
> > > such as updating display configuration during the vblank. It controls
> > > Global Command Engine (GCE) hardware to achieve this requirement.
> > > Currently, CMDQ only supports display related hardwares, but we expect
> > > it can be extended to other hardwares for future requirements.
> > > 
> > > Signed-off-by: Houlong Wei <houlong.wei@mediatek.com>
> > > Signed-off-by: HS Liao <hs.liao@mediatek.com>
> > > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > > ---
> > >  drivers/mailbox/Kconfig                  |   10 +
> > >  drivers/mailbox/Makefile                 |    2 +
> > >  drivers/mailbox/mtk-cmdq-mailbox.c       |  594 ++++++++++++++++++++++++++++++
> > >  include/linux/mailbox/mtk-cmdq-mailbox.h |   77 ++++
> > >  4 files changed, 683 insertions(+)
> > >  create mode 100644 drivers/mailbox/mtk-cmdq-mailbox.c
> > >  create mode 100644 include/linux/mailbox/mtk-cmdq-mailbox.h
> > > 
> > > diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
> > > index ba2f152..43bb26f 100644
> > > --- a/drivers/mailbox/Kconfig
> > > +++ b/drivers/mailbox/Kconfig
> > > @@ -171,4 +171,14 @@ config BCM_FLEXRM_MBOX
> > >  	  Mailbox implementation of the Broadcom FlexRM ring manager,
> > >  	  which provides access to various offload engines on Broadcom
> > >  	  SoCs. Say Y here if you want to use the Broadcom FlexRM.
> > > +

[...]

> > > +
> > > +static void cmdq_task_exec(struct cmdq_pkt *pkt, struct cmdq_thread *thread)
> > > +{
> > > +	struct cmdq *cmdq;
> > > +	struct cmdq_task *task;
> > > +	unsigned long curr_pa, end_pa;
> > > +
> > > +	cmdq = dev_get_drvdata(thread->chan->mbox->dev);
> > > +
> > > +	/* Client should not flush new tasks if suspended. */
> > > +	WARN_ON(cmdq->suspended);
> > > +
> > > +	task = kzalloc(sizeof(*task), GFP_ATOMIC);
> > > +	task->cmdq = cmdq;
> > > +	INIT_LIST_HEAD(&task->list_entry);
> > > +	task->pa_base = pkt->pa_base;
> > > +	task->thread = thread;
> > > +	task->pkt = pkt;
> > > +
> > > +	if (list_empty(&thread->task_busy_list)) {
> > > +		WARN_ON(clk_enable(cmdq->clock) < 0);
> > > +		WARN_ON(cmdq_thread_reset(cmdq, thread) < 0);
> > > +
> > > +		writel(task->pa_base, thread->base + CMDQ_THR_CURR_ADDR);
> > > +		writel(task->pa_base + pkt->cmd_buf_size,
> > > +		       thread->base + CMDQ_THR_END_ADDR);
> > > +		writel(CMDQ_THR_IRQ_EN, thread->base + CMDQ_THR_IRQ_ENABLE);
> > > +		writel(CMDQ_THR_ENABLED, thread->base + CMDQ_THR_ENABLE_TASK);
> > > +
> > > +		mod_timer(&thread->timeout,
> > > +			  jiffies + msecs_to_jiffies(CMDQ_TIMEOUT_MS));
> > > +	} else {
> > > +		WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0);
> > > +		curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR);
> > > +		end_pa = readl(thread->base + CMDQ_THR_END_ADDR);
> > > +
> > > +		/*
> > > +		 * Atomic execution should remove the following wfe, i.e. only
> > > +		 * wait event at first task, and prevent to pause when running.
> > > +		 */
> > > +		if (thread->atomic_exec) {
> > > +			/* GCE is executing if command is not WFE */
> > > +			if (!cmdq_thread_is_in_wfe(thread)) {
> > > +				cmdq_thread_resume(thread);
> > > +				cmdq_thread_wait_end(thread, end_pa);
> > > +				WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0);
> > > +				/* set to this task directly */
> > > +				writel(task->pa_base,
> > > +				       thread->base + CMDQ_THR_CURR_ADDR);
> > > +			} else {
> > > +				cmdq_task_insert_into_thread(task);
> > > +				cmdq_task_remove_wfe(task);
> > > +				smp_mb(); /* modify jump before enable thread */
> > > +			}
> > > +		} else {
> > > +			/* check boundary */
> > > +			if (curr_pa == end_pa - CMDQ_INST_SIZE ||
> > > +			    curr_pa == end_pa) {
> > > +				/* set to this task directly */
> > > +				writel(task->pa_base,
> > > +				       thread->base + CMDQ_THR_CURR_ADDR);
> > > +			} else {
> > > +				cmdq_task_insert_into_thread(task);
> > > +				smp_mb(); /* modify jump before enable thread */
> > > +			}
> > > +		}
> > > +		writel(task->pa_base + pkt->cmd_buf_size,
> > > +		       thread->base + CMDQ_THR_END_ADDR);
> > > +		cmdq_thread_resume(thread);
> > > +	}
> > > +	list_move_tail(&task->list_entry, &thread->task_busy_list);
> > 
> > You implement a list to queue command because you need to execute
> > multiple packet in the same vblank period. I've a suggestion that you
> > need not to implement a list. Once cmdq driver receive two packet as
> > below:
> > 
> > Packet 1:
> > (1) clear vblank event
> > (2) wait vblank event
> > (3) write register setting 1
> > (4) no operation
> > 
> > Packet 2:
> > (1) clear vblank event
> > (2) wait vblank event
> > (3) write register setting 2
> > (4) no operation
> > 
> > In your current design, you modify these two packet as:
> > 
> > Packet 1:
> > (1) clear vblank event
> > (2) wait vblank event
> > (3) write register setting 1
> > (4) Jump to packet 2 (modified)
> > 
> > Packet 2:
> > (1) no operation (modified)
> > (2) no operation (modified)
> > (3) write register setting 2
> > (4) no operation
> > 
> > So the register setting 1 and register setting 2 could be executed in
> > the same vblank period.
> > 
> > My suggestion is: when the client want to send packet 2, it 'abort'
> > packet 1 at first. The 'abort' means remove it from channel. In current
> > mailbox interface, mbox_free_channel() is most like abort function, but
> > my abort would keep the channel. So maybe you need to implement a new
> > mailbox interface which could remove packet in the channel. So the step
> > would be:
> > 
> > (1) Client generate packet 1 which include write register setting 1
> > (2) Client send packet 1 to channel A
> > 
> > When client want to send register setting 2,
> > 
> > (3) Client abort channel A
> > (4) Client generate packet 2 which include write register setting 1 & 2
> > (5) Client send packet 2 to channel A
> > 
> > Once you have the abort function, you could use the queue mechanism in
> > mailbox core instead of implementing your own.
> > 
> > For the client which have the atomic requirement, it also need not to
> > implement a list to keep what command have not executed. So the abort
> > interface would make client and controller much simpler.
> > 
> > Regards,
> > CK
> > 
> 
> Hi CK, thanks for you suggestion. Since current mailbox framework has
> no 'abort' function and need add new interface. It may be complicated
> to do this. Could we keep current solution?
> 

I imagine that 'abort' is a simple function. Is my imagination
incorrect? So you would like choose implementing a complicated queue
mechanism in mtk_cmdq driver rather than implementing abort function.
Maybe both are complicated.

I think the more important thing is that do you and maintainer agree to
implement abort function which could reduce mtk-self-queue in mtk_cmdq
driver. If the answer is yes, there could be two patch sequence A and B,
the patch sequence A is

A.1 mtk_cmdq driver with mtk-self-queue.
A.2 mtk display driver use mtk_cmdq without abort function.
A.3 add mailbox abort function
A.4 mtk_cmdq driver support abort function and remove mtk-self-queue.
A.5 mtk display driver use mtk_cmdq with abort function

And the patch sequence B is

B.1 add mailbox abort function
B.2 mtk_cmdq driver with abort function and no mtk-self-queue
B.3 mtk display driver use mtk_cmdq with abort function

Which one do you think is complicated?

So let's back to the more important thing: 'do you agree to implement
abort function which could reduce mtk-self-queue in mtk_cmdq driver?'

Regards,
CK

> > > +}
> > > +

[...]

> 

  reply	other threads:[~2018-06-28  1:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  7:28 [PATCH v21 0/4] Mediatek MT8173 CMDQ support houlong.wei
2018-01-31  7:28 ` [PATCH v21 1/4] dt-bindings: soc: Add documentation for the MediaTek GCE unit houlong.wei
2018-01-31  7:28 ` [PATCH v21 2/4] mailbox: mediatek: Add Mediatek CMDQ driver houlong.wei
     [not found]   ` <1517383693-25591-3-git-send-email-houlong.wei-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2018-02-21  3:53     ` CK Hu
2018-06-27 11:53       ` houlong wei
2018-06-28  1:57         ` CK Hu [this message]
2018-06-28  6:55           ` houlong wei
2018-01-31  7:28 ` [PATCH v21 3/4] arm64: dts: mt8173: Add GCE node houlong.wei
2018-01-31  7:28 ` [PATCH v21 4/4] soc: mediatek: Add Mediatek CMDQ helper houlong.wei
     [not found]   ` <1517383693-25591-5-git-send-email-houlong.wei-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2018-02-06  2:52     ` CK Hu
2018-02-08  9:02       ` houlong wei
2018-06-27 11:32       ` houlong wei
2018-02-21  8:05     ` CK Hu
2018-06-27 11:43       ` houlong wei
2018-06-28  1:07         ` CK Hu

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=1530151059.6193.27.camel@mtksdaap41 \
    --to=ck.hu@mediatek.com \
    --cc=cawa.cheng@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=drinkcat@chromium.org \
    --cc=houlong.wei@mediatek.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=kernel@pengutronix.de \
    --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=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).