linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Sameer Pujar <spujar@nvidia.com>, Jon Hunter <jonathanh@nvidia.com>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
	broonie@kernel.org, atalambedu@nvidia.com, tiwai@suse.com,
	viswanathl@nvidia.com, linux-tegra@vger.kernel.org,
	robh+dt@kernel.org, thierry.reding@gmail.com, sharadg@nvidia.com,
	rlokhande@nvidia.com, mkumard@nvidia.com, dramesh@nvidia.com
Subject: Re: [alsa-devel] [PATCH 4/9] ASoC: tegra: add Tegra210 based I2S driver
Date: Wed, 29 Jan 2020 06:41:59 +0300	[thread overview]
Message-ID: <3b42c858-733b-0d17-f457-8043d97f5058@gmail.com> (raw)
In-Reply-To: <c6022a93-b79a-c691-1d75-d007d0b64ead@nvidia.com>

27.01.2020 08:22, Sameer Pujar пишет:
> 
> 
> On 1/24/2020 7:34 PM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 24.01.2020 12:51, Jon Hunter пишет:
>>> On 24/01/2020 09:07, Jon Hunter wrote:
>>>> On 23/01/2020 15:16, Dmitry Osipenko wrote:
>>>>> 23.01.2020 12:22, Sameer Pujar пишет:
>>>>>>
>>>>>> On 1/22/2020 9:57 PM, Dmitry Osipenko wrote:
>>>>>>> External email: Use caution opening links or attachments
>>>>>>>
>>>>>>>
>>>>>>> 22.01.2020 14:52, Jon Hunter пишет:
>>>>>>>> On 22/01/2020 07:16, Sameer Pujar wrote:
>>>>>>>>
>>>>>>>> ...
>>>>>>>>
>>>>>>>>>>>>>>> +static int tegra210_i2s_remove(struct platform_device
>>>>>>>>>>>>>>> *pdev)
>>>>>>>>>>>>>>> +{
>>>>>>>>>>>>>>> +     pm_runtime_disable(&pdev->dev);
>>>>>>>>>>>>>>> +     if (!pm_runtime_status_suspended(&pdev->dev))
>>>>>>>>>>>>>>> +             tegra210_i2s_runtime_suspend(&pdev->dev);
>>>>>>>>>>>>>> This breaks device's RPM refcounting if it was disabled in
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>> active
>>>>>>>>>>>>>> state. This code should be removed. At most you could warn
>>>>>>>>>>>>>> about the
>>>>>>>>>>>>>> unxpected RPM state here, but it shouldn't be necessary.
>>>>>>>>>>>>> I guess this was added for safety and explicit suspend
>>>>>>>>>>>>> keeps clock
>>>>>>>>>>>>> disabled.
>>>>>>>>>>>>> Not sure if ref-counting of the device matters when runtime
>>>>>>>>>>>>> PM is
>>>>>>>>>>>>> disabled and device is removed.
>>>>>>>>>>>>> I see few drivers using this way.
>>>>>>>>>>>> It should matter (if I'm not missing something) because RPM
>>>>>>>>>>>> should
>>>>>>>>>>>> be in
>>>>>>>>>>>> a wrecked state once you'll try to re-load the driver's module.
>>>>>>>>>>>> Likely
>>>>>>>>>>>> that those few other drivers are wrong.
>>>>>>>>>>>>
>>>>>>>>>>>> [snip]
>>>>>>>>>>> Once the driver is re-loaded and RPM is enabled, I don't
>>>>>>>>>>> think it
>>>>>>>>>>> would use
>>>>>>>>>>> the same 'dev' and the corresponding ref count. Doesn't it
>>>>>>>>>>> use the
>>>>>>>>>>> new
>>>>>>>>>>> counters?
>>>>>>>>>>> If RPM is not working for some reason, most likely it would
>>>>>>>>>>> be the
>>>>>>>>>>> case
>>>>>>>>>>> for other
>>>>>>>>>>> devices. What best driver can do is probably do a force suspend
>>>>>>>>>>> during
>>>>>>>>>>> removal if
>>>>>>>>>>> already not done. I would prefer to keep, since multiple drivers
>>>>>>>>>>> still
>>>>>>>>>>> have it,
>>>>>>>>>>> unless there is a real harm in doing so.
>>>>>>>>>> I took a closer look and looks like the counter actually
>>>>>>>>>> should be
>>>>>>>>>> reset. Still I don't think that it's a good practice to make
>>>>>>>>>> changes
>>>>>>>>>> underneath of RPM, it may strike back.
>>>>>>>>> If RPM is broken, it probably would have been caught during device
>>>>>>>>> usage.
>>>>>>>>> I will remove explicit suspend here if no any concerns from other
>>>>>>>>> folks.
>>>>>>>>> Thanks.
>>>>>>>> I recall that this was the preferred way of doing this from the RPM
>>>>>>>> folks. Tegra30 I2S driver does the same and Stephen had pointed
>>>>>>>> me to
>>>>>>>> this as a reference.
>>>>>>>> I believe that this is meant to ensure that the
>>>>>>>> device is always powered-off regardless of it RPM is enabled or
>>>>>>>> not and
>>>>>>>> what the current state is.
>>>>>>> Yes, it was kinda actual for the case of unavailable RPM.
>>>>>>> Anyways, /I think/ variant like this should have been more
>>>>>>> preferred:
>>>>>>>
>>>>>>> if (!pm_runtime_enabled(&pdev->dev))
>>>>>>>           tegra210_i2s_runtime_suspend(&pdev->dev);
>>>>>>> else
>>>>>>>           pm_runtime_disable(&pdev->dev);
>>>>>> I think it looks to be similar to what is there already.
>>>>>>
>>>>>> pm_runtime_disable(&pdev->dev); // it would turn out to be a dummy
>>>>>> call
>>>>>> if !RPM
>>>>>> if (!pm_runtime_status_suspended(&pdev->dev)) // it is true always
>>>>>> if !RPM
>>>>>>          tegra210_i2s_runtime_suspend(&pdev->dev);
>>>>> Maybe this is fine for !RPM, but not really fine in a case of enabled
>>>>> RPM. Device could be in resumed state after pm_runtime_disable() if it
>>>>> wasn't suspended before the disabling.
>>>> I don't see any problem with this for the !RPM case.
>>> Sorry I meant the RPM case. In other words, I don't see a problem for
>>> neither the RPM case of the !RPM case.
>> 1. Device shall be in RPM-suspended state at the time of driver's
>> removal, unless there is a bug in the sound driver. Hence why do you
>> need the dead code which doesn't bring any practical value?
>>
>> 2. Making changes underneath of RPM is simply error-prone. It may hit
>> badly in the future once something will change in the RPM core.
> 
> I think we are stretching a bit more here when there is no any real harm.
> Right now it works well for both RPM and !RPM case and if we really need to
> fix something in future we can fix. Since my initial inclination was
> keeping
> the code as it is and Jon also has similar thoughts, I would retain this
> code.
> Sorry Dmitry, we can fix if something comes up and many other drivers would
> need this at that time.

The !RPM case isn't supported by Tegra anymore in upstream kernel. I'm
trying to help to make yours driver better and gave you reasons to
remove the unneeded code, while you're keep saying that "there is no
harm to retain it", which is not a reason to clutter up the code. I
don't feel that it's worthwhile to continue arguing here.

  reply	other threads:[~2020-01-29  3:42 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 14:23 [PATCH 0/9] add ASoC components for AHUB Sameer Pujar
2020-01-20 14:23 ` [PATCH 1/9] dt-bindings: sound: tegra: add DT binding " Sameer Pujar
2020-01-20 14:23 ` [PATCH 2/9] ASoC: tegra: add support for CIF programming Sameer Pujar
2020-01-20 15:58   ` [alsa-devel] " Dmitry Osipenko
2020-01-21  4:41     ` Sameer Pujar
2020-01-21 16:04       ` Dmitry Osipenko
2020-01-27  5:11         ` Sameer Pujar
2020-01-28 22:40           ` Dmitry Osipenko
2020-01-20 14:23 ` [PATCH 3/9] ASoC: tegra: add Tegra210 based DMIC driver Sameer Pujar
2020-01-20 14:23 ` [PATCH 4/9] ASoC: tegra: add Tegra210 based I2S driver Sameer Pujar
2020-01-21  5:15   ` [alsa-devel] " Dmitry Osipenko
2020-01-21 14:21     ` Sameer Pujar
2020-01-21 16:03       ` Dmitry Osipenko
2020-01-22  4:32         ` Sameer Pujar
2020-01-22  6:23           ` Dmitry Osipenko
2020-01-22  7:16             ` Sameer Pujar
2020-01-22 11:52               ` Jon Hunter
2020-01-22 16:27                 ` Dmitry Osipenko
2020-01-23  9:22                   ` Sameer Pujar
2020-01-23 15:16                     ` Dmitry Osipenko
2020-01-24  9:07                       ` Jon Hunter
2020-01-24  9:51                         ` Jon Hunter
2020-01-24 14:04                           ` Dmitry Osipenko
2020-01-27  5:22                             ` Sameer Pujar
2020-01-29  3:41                               ` Dmitry Osipenko [this message]
2020-02-14 14:05                                 ` Jon Hunter
2020-02-18  1:00                                   ` Dmitry Osipenko
2020-02-19 16:10                                     ` Sameer Pujar
2020-01-22 16:26               ` Dmitry Osipenko
2020-01-20 14:23 ` [PATCH 5/9] ASoC: tegra: add Tegra210 based AHUB driver Sameer Pujar
2020-01-24  1:18   ` [alsa-devel] " Dmitry Osipenko
2020-01-24  3:39     ` Sameer Pujar
2020-01-24  4:28       ` Dmitry Osipenko
2020-01-27  9:45     ` Jon Hunter
2020-01-20 14:23 ` [PATCH 6/9] ASoC: tegra: add Tegra186 based DSPK driver Sameer Pujar
2020-01-20 14:23 ` [PATCH 7/9] ASoC: tegra: add Tegra210 based ADMAIF driver Sameer Pujar
2020-01-24  1:28   ` [alsa-devel] " Dmitry Osipenko
2020-01-24  3:27     ` Sameer Pujar
2020-01-24  4:25       ` Dmitry Osipenko
2020-01-27  5:08         ` Sameer Pujar
2020-01-20 14:23 ` [PATCH 8/9] arm64: tegra: add AHUB components for few Tegra chips Sameer Pujar
2020-01-20 14:23 ` [PATCH 9/9] arm64: tegra: enable AHUB modules " Sameer Pujar
2020-01-28 10:49 ` [PATCH 0/9] add ASoC components for AHUB Sameer Pujar

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=3b42c858-733b-0d17-f457-8043d97f5058@gmail.com \
    --to=digetx@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=atalambedu@nvidia.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dramesh@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=rlokhande@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=sharadg@nvidia.com \
    --cc=spujar@nvidia.com \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    --cc=viswanathl@nvidia.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).