From: jilaiw@codeaurora.org
To: Bjorn Andersson <bjorn@kryo.se>
Cc: Jilai Wang <jilaiw@codeaurora.org>,
Rob Clark <robdclark@gmail.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
linux-arm-msm <linux-arm-msm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] drm/msm/hdmi: add hdmi hdcp support
Date: Wed, 3 Dec 2014 17:49:19 -0000 [thread overview]
Message-ID: <250d9d48a62a2a46dba33a6f888fdd9e.squirrel@codeaurora.org> (raw)
In-Reply-To: <CAJAp7Oj7=v=ewdDa7USif+Ojdkym5wQyX0HtBky5JracN6phtA@mail.gmail.com>
> On Wed, Dec 3, 2014 at 9:16 AM, <jilaiw@codeaurora.org> wrote:
> [..]
>>>>> + enum hdmi_hdcp_state hdcp_state;
>>>>> + struct mutex state_mutex;
>>>>> + struct delayed_work hdcp_reauth_work;
>>>>> + struct delayed_work hdcp_auth_part1_1_work;
>>>>> + struct delayed_work hdcp_auth_part1_2_work;
>>>>> + struct work_struct hdcp_auth_part1_3_work;
>>>>> + struct delayed_work hdcp_auth_part2_1_work;
>>>>> + struct delayed_work hdcp_auth_part2_2_work;
>>>>> + struct delayed_work hdcp_auth_part2_3_work;
>>>>> + struct delayed_work hdcp_auth_part2_4_work;
>>>>> + struct work_struct hdcp_auth_prepare_work;
>>>>
>>>> You shouldn't use "work" as a way to express states in your state
>>>> machine.
>>>> Better have 1 auth work function that does all these steps, probably
>>>> having
>>>> them split in functions just like you do now.
>>>>
>>>> That way you can have 1 function running the pass of authentication,
>>>> starting
>>>> by checking if you're reauthing or not then processing each step one
>>>> by
>>>> one,
>>>> sleeping inbetween them. You can have the functions return -EAGAIN to
>>>> indicate
>>>> that you need to retry the current operation and so on.
>>>>
>>>> This would split the state machine from the state executioners and
>>>> simplify
>>>> your code.
>>>
>>> As a side note (disclaimer, I'm not an hdcp expert), but I wonder if
>>> eventually some of that should be extracted out into some helpers in
>>> drm core. I guess that is something we'll figure out when a 2nd
>>> driver gains upstream HDCP support. One big work w/ msleep()'s does
>>> sound like it would be easier to understand (and therefore easier to
>>> refactor out into helpers).
>>>
>>> [snip]
>>>
>>
>> The reason that I break the partI/PartII work into these small works
>> because I want to avoid to use msleep in work.
>> Otherwise cancel a HDCP work may cause long delay up to several seconds.
>>
>
> I definitely think the steps are nice size and make things easy to
> understand.
>
> If you make the steps that require a retry return out to the main
> state handling function with a -EAGAIN, then you can have check if you
> should retry or abort based on cancellation. Giving you the worst case
> cancellation time of the longest sleep...
>
> As Rob suggest you could use wait_event_timeout() or something to
> improve this, but on the other hand the worst case here seems to be
> the HZ/2 after prepare_auth; others are HZ/8, HZ/20 and HZ/50; not
> "seconds".
>
> So I would start with a simple msleep() for implementation simplicity
> and then enhance that in a follow up commit (if needed)...
>
> Regards,
> Bjorn
>
The worst wait time could be 5 seconds if the downstream device is a
REPEATER. The maximum retry time is set to 100 and the delay for each time
is HZ/20, then the maximum wait time before abort will be 5 seconds.
As you suggested, I can use the flag to notify the retry process to abort
earlier in case this work needs to be canceled which can reduce the delay
to HZ/20 then. Or as Rob's suggestion to wait for hpd event.
Thanks,
Jilai
next prev parent reply other threads:[~2014-12-03 17:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-01 21:56 [PATCH 2/2] drm/msm/hdmi: add hdmi hdcp support Jilai Wang
2014-12-03 1:46 ` Bjorn Andersson
2014-12-03 16:42 ` Rob Clark
2014-12-03 17:16 ` jilaiw
2014-12-03 17:20 ` Rob Clark
2014-12-03 17:32 ` Bjorn Andersson
2014-12-03 17:49 ` jilaiw [this message]
2015-01-13 20:43 ` [PATCH 2/2] drm/msm/hdmi: add hdmi hdcp support (V2) Jilai Wang
2015-01-30 21:51 ` Bjorn Andersson
2015-01-30 22:39 ` Bjorn Andersson
2015-02-10 19:34 ` Bjorn Andersson
2015-02-11 18:59 ` jilaiw
2015-02-11 22:23 ` Bjorn Andersson
2015-04-02 21:49 ` [PATCH] drm/msm/hdmi: add hdmi hdcp support (V3) Jilai Wang
2014-12-03 16:51 ` [PATCH 2/2] drm/msm/hdmi: add hdmi hdcp support Rob Clark
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=250d9d48a62a2a46dba33a6f888fdd9e.squirrel@codeaurora.org \
--to=jilaiw@codeaurora.org \
--cc=bjorn@kryo.se \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robdclark@gmail.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).