devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Swapnil Jakhade <sjakhade@cadence.com>
Cc: <airlied@linux.ie>, <daniel@ffwll.ch>, <robh+dt@kernel.org>,
	<a.hajda@samsung.com>, <narmstrong@baylibre.com>,
	<jonas@kwiboo.se>, <jernej.skrabec@siol.net>,
	<dri-devel@lists.freedesktop.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <mparab@cadence.com>,
	<yamonkar@cadence.com>, <jsarha@ti.com>, <nsekhar@ti.com>,
	<praneeth@ti.com>
Subject: Re: [PATCH v8 2/3] drm: bridge: Add support for Cadence MHDP DPI/DP bridge
Date: Fri, 14 Aug 2020 12:29:35 +0300	[thread overview]
Message-ID: <49c2a4c8-6d84-6164-d350-6a985fc9a3e9@ti.com> (raw)
In-Reply-To: <20200811023622.GC13513@pendragon.ideasonboard.com>

On 11/08/2020 05:36, Laurent Pinchart wrote:

>> +static int cdns_mhdp_mailbox_write(struct cdns_mhdp_device *mhdp, u8 val)
>> +{
>> +	int ret, full;
>> +
>> +	WARN_ON(!mutex_is_locked(&mhdp->mbox_mutex));
>> +
>> +	ret = readx_poll_timeout(readl, mhdp->regs + CDNS_MAILBOX_FULL,
>> +				 full, !full, MAILBOX_RETRY_US,
>> +				 MAILBOX_TIMEOUT_US);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	writel(val, mhdp->regs + CDNS_MAILBOX_TX_DATA);
>> +
>> +	return 0;
>> +}
> 
> As commented previously, I think there's room for optimization here. Two
> options that I think should be investigated are using the mailbox
> interrupts, and only polling for the first byte of the message
> (depending on whether the firmware implementation can guarantee that
> when the first byte is available, the rest of the message will be
> immediately available too). This can be done on top of this patch
> though.

I made some tests on this.

I cannot see mailbox_write ever looping, mailbox is never full. So in this case the
readx_poll_timeout() call is there just for safety to catch the cases where something has gone
totally wrong or perhaps once in a while the mbox can be full for a tiny moment. But we always do
need to check CDNS_MAILBOX_FULL before each write to CDNS_MAILBOX_TX_DATA, so we can as well use
readx_poll_timeout for that to catch the odd cases (afaics, there's no real overhead if the exit
condition is true immediately).

mailbox_read polls sometimes. Most often it does not poll, as the data is ready in the mbox, and in
these cases the situation is the same as for mailbox_write.

The cases where it does poll are related to things where the fw has to wait for something. The
longest poll waits seemed to be EDID read (16 ms wait) and adjusting LT (1.7 ms wait). And afaics,
when the first byte of the received message is there, the rest of the bytes will be available
without wait.

For mailbox_write and for most mailbox_reads I think using interrupts makes no sense, as the
overhead would be big.

For those few long read operations, interrupts would make sense. I guess a simple way to handle this
would be to add a new function, wait_for_mbox_data() or such, which would use the interrupts to wait
for mbox not empty. This function could be used in selected functions (edid, LT) after
cdns_mhdp_mailbox_send().

Although I think it's not that bad currently, MAILBOX_RETRY_US is 1ms, so it's quite lazy polling,
so perhaps this can be considered TODO optimization.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2020-08-14  9:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 11:34 [PATCH v8 0/3] drm: Add support for Cadence MHDP DPI/DP bridge and J721E wrapper Swapnil Jakhade
2020-08-06 11:34 ` [PATCH v8 1/3] dt-bindings: drm/bridge: Document Cadence MHDP bridge bindings Swapnil Jakhade
2020-08-11  0:36   ` Laurent Pinchart
2020-08-14  7:13     ` Tomi Valkeinen
2020-08-06 11:34 ` [PATCH v8 2/3] drm: bridge: Add support for Cadence MHDP DPI/DP bridge Swapnil Jakhade
2020-08-07  1:15   ` kernel test robot
2020-08-07  9:38   ` Tomi Valkeinen
2020-08-11  2:36   ` Laurent Pinchart
2020-08-14  8:22     ` Tomi Valkeinen
2020-08-24  2:17       ` Laurent Pinchart
2020-08-14  9:29     ` Tomi Valkeinen [this message]
2020-08-24  2:18       ` Laurent Pinchart
2020-08-26  7:26     ` Tomi Valkeinen
2020-08-06 11:34 ` [PATCH v8 3/3] drm: bridge: cdns-mhdp: Add j721e wrapper Swapnil Jakhade
2020-08-11  2:41   ` Laurent Pinchart
2020-08-12  8:39 ` [PATCH v8 0/3] drm: Add support for Cadence MHDP DPI/DP bridge and J721E wrapper Guido Günther
2020-08-12 10:47   ` Tomi Valkeinen
2020-08-12 13:56     ` Guido Günther
2020-08-24  7:16       ` Swapnil Kashinath Jakhade
2020-08-25  7:32         ` Guido Günther

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=49c2a4c8-6d84-6164-d350-6a985fc9a3e9@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@siol.net \
    --cc=jonas@kwiboo.se \
    --cc=jsarha@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mparab@cadence.com \
    --cc=narmstrong@baylibre.com \
    --cc=nsekhar@ti.com \
    --cc=praneeth@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=sjakhade@cadence.com \
    --cc=yamonkar@cadence.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).