From: vishnu <vravulap@amd.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Ravulapati Vishnu vardhan rao
<Vishnuvardhanrao.Ravulapati@amd.com>
Cc: Alexander.Deucher@amd.com, djkurtz@google.com,
Akshu.Agrawal@amd.com, Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
YueHaibing <yuehaibing@huawei.com>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
MANAGEM..." <alsa-devel@alsa-project.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [RESEND PATCH v9 6/6] ASoC: amd: Added ACP3x system resume and runtime pm
Date: Tue, 19 Nov 2019 18:26:17 +0530 [thread overview]
Message-ID: <3321478e-de8f-2eb6-6e6f-6eb621b8434b@amd.com> (raw)
In-Reply-To: <20191119123531.GA30789@kadam>
On 19/11/19 6:05 PM, Dan Carpenter wrote:
> I can't apply this because I'm not CC'd on patches 2-5.
>
> On Tue, Nov 19, 2019 at 05:41:16PM +0530, Ravulapati Vishnu vardhan rao wrote:
>> +static int acp3x_power_on(void __iomem *acp3x_base)
>> +{
>> + u32 val;
>> + u32 timeout;
>> +
>> + timeout = 0;
>> + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
>> +
>> + if (val == 0)
>> + return val;
>> +
>> + if (!((val & ACP_PGFSM_STATUS_MASK) ==
>> + ACP_POWER_ON_IN_PROGRESS))
>> + rv_writel(ACP_PGFSM_CNTL_POWER_ON_MASK,
>> + acp3x_base + mmACP_PGFSM_CONTROL);
>> + while (++timeout) {
>
> while (++timeout < 500)
>
If I check with timeout<500 and in next condition i have
if(timeout >500) this never happens.
Our intention is to wait for time out and exit.
>> + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
> ^^
> Extra space character.
>
>
>> + if (!val)
>> + break;
>
> return 0;
>
>> + udelay(1);
>> + if (timeout > 500) {
>> + pr_err("ACP is Not Powered ON\n");
>> + return -ETIMEDOUT;
>> + }
>> + }
>> + return 0;
>
> Since we combined the ++timeout and the < 500 this becomes
> "return -ETIMEOUT;" here.
>
>
>> +}
>> +
>> +static int acp3x_power_off(void __iomem *acp3x_base)
>> +{
>> + u32 val;
>> + u32 timeout, ret;
>
> Both ret and timeout should just be int. Please update this throughout.
>
>> +
>> + timeout = 0;
>
> Move the timeout = 0 next to the loop or put it in the initializer.
>
>> + rv_writel(ACP_PGFSM_CNTL_POWER_OFF_MASK,
>> + acp3x_base + mmACP_PGFSM_CONTROL);
>> + while (++timeout) {
>
> while (++timeout < 500) {
>
>> + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS);
>
> Extra space char.
>
>> + if ((val & ACP_PGFSM_STATUS_MASK) == ACP_POWERED_OFF) {
>> + ret = 0;
>> + break;
>
> return 0;
>
>> + }
>> + udelay(1);
>> + if (timeout > 500) {
>> + pr_err("ACP is Not Powered OFF\n");
>> + ret = -ETIMEDOUT;
>> + break;
>> + }
>> + }
>> + return ret;
>> +}
>> +
>> +static int acp3x_reset(void __iomem *acp3x_base)
>> +{
>> + u32 val, timeout;
>> +
>> + rv_writel(1, acp3x_base + mmACP_SOFT_RESET);
>> + timeout = 0;
>> + while (++timeout) {
>> + val = rv_readl(acp3x_base + mmACP_SOFT_RESET);
>> + if ((val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) ||
>> + timeout > 100) {
>
> This timeout > 100 limit was difficult to spot. Like finding Waldo.
>
>> + if (val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK)
>> + break;
>
> This is a duplicate condition.
>
>> + return -ENODEV;
>> + }
>> + cpu_relax();
>> + }
>> + rv_writel(0, acp3x_base + mmACP_SOFT_RESET);
>> + timeout = 0;
>> + while (++timeout) {
>> + val = rv_readl(acp3x_base + mmACP_SOFT_RESET);
>> + if (!val)
>> + break;
>> + if (timeout > 100)
>> + return -ENODEV;
>> + cpu_relax();
>> + }
>> + return 0;
>> +}
>> +
>> +static int acp3x_init(void __iomem *acp3x_base)
>> +{
>> + int ret;
>> +
>> + /* power on */
>> + ret = acp3x_power_on(acp3x_base);
>> + if (ret) {
>> + pr_err("ACP3x power on failed\n");
>> + return ret;
>> + }
>> + /* Reset */
>> + ret = acp3x_reset(acp3x_base);
>> + if (ret) {
>> + pr_err("ACP3x reset failed\n");
>> + return ret;
>> + }
>> + return 0;
>> +}
>> +
>> +static int acp3x_deinit(void __iomem *acp3x_base)
>> +{
>> + int ret;
>> +
>> + /* Reset */
>> + ret = acp3x_reset(acp3x_base);
>> + if (ret) {
>> + pr_err("ACP3x reset failed\n");
>> + return ret;
>> + }
>> + /* power off */
>> + ret = acp3x_power_off(acp3x_base);
>> + if (ret) {
>> + pr_err("ACP3x power off failed\n");
>> + return ret;
>> + }
>> + return 0;
>> +}
>> +
>> static int snd_acp3x_probe(struct pci_dev *pci,
>> const struct pci_device_id *pci_id)
>> {
>> @@ -64,6 +186,9 @@ static int snd_acp3x_probe(struct pci_dev *pci,
>> }
>> pci_set_master(pci);
>> pci_set_drvdata(pci, adata);
>> + ret = acp3x_init(adata->acp3x_base);
>> + if (ret)
>> + goto disable_msi;
>>
>> val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG);
>> switch (val) {
>> @@ -73,7 +198,7 @@ static int snd_acp3x_probe(struct pci_dev *pci,
>> GFP_KERNEL);
>> if (!adata->res) {
>> ret = -ENOMEM;
>> - goto disable_msi;
>> + goto de_init;
>> }
>>
>> adata->res[0].name = "acp3x_i2s_iomem";
>> @@ -134,12 +259,23 @@ static int snd_acp3x_probe(struct pci_dev *pci,
>> ret = -ENODEV;
>> goto disable_msi;
>> }
>> + pm_runtime_set_autosuspend_delay(&pci->dev, 5000);
>> + pm_runtime_use_autosuspend(&pci->dev);
>> + pm_runtime_set_active(&pci->dev);
>> + pm_runtime_put_noidle(&pci->dev);
>> + pm_runtime_enable(&pci->dev);
>> return 0;
>>
>> unregister_devs:
>> if (val == I2S_MODE)
>> for (i = 0 ; i < ACP3x_DEVS ; i++)
>> platform_device_unregister(adata->pdev[i]);
>> +de_init:
>> + ret = acp3x_deinit(adata->acp3x_base);
>> + if (ret)
>> + dev_err(&pci->dev, "ACP de-init failed\n");
>> + else
>> + dev_dbg(&pci->dev, "ACP de-initialized\n");
>
>
> We can't overwrite ret (probe failed even if deinit() succeeded). I
> dont' know that the debug printk is useful.
>
> de_init:
> if (acp3x_deinit(adata->acp3x_base))
> dev_err(&pci->dev, "ACP de-init failed in probe error handling\n");
>
>
>> disable_msi:
>> pci_disable_msi(pci);
>> release_regions:
>> @@ -150,15 +286,58 @@ static int snd_acp3x_probe(struct pci_dev *pci,
>> return ret;
>> }
>>
>> +static int snd_acp3x_suspend(struct device *dev)
> ^^
> Extra space char
>
>> +{
>> + int status;
>
> int ret;
>
>> + struct acp3x_dev_data *adata;
>> +
>> + adata = dev_get_drvdata(dev);
>> + status = acp3x_deinit(adata->acp3x_base);
>> + if (status)
>> + dev_err(dev, "ACP de-init failed\n");
>> + else
>> + dev_dbg(dev, "ACP de-initialized\n");
>> +
>> + return 0;
>> +}
>> +
>> +static int snd_acp3x_resume(struct device *dev)
> ^^
> Extra space
>
>> +{
>> + int status;
>> + struct acp3x_dev_data *adata;
>> +
>> + adata = dev_get_drvdata(dev);
>> + status = acp3x_init(adata->acp3x_base);
>> + if (status) {
>> + dev_err(dev, "ACP init failed\n");
>> + return status;
>> + }
>> + return 0;
>> +}
>> +
>> +static const struct dev_pm_ops acp3x_pm = {
>> + .runtime_suspend = snd_acp3x_suspend,
>> + .runtime_resume = snd_acp3x_resume,
>> + .resume = snd_acp3x_resume,
>
> Fix whitespace.
>
>> +};
>> +
>> static void snd_acp3x_remove(struct pci_dev *pci)
>> {
>> - struct acp3x_dev_data *adata = pci_get_drvdata(pci);
>
> This was fine. Leave it as-is.
>
>> - int i;
>> + struct acp3x_dev_data *adata;
>> + int i, ret;
>>
>> + adata = pci_get_drvdata(pci);
>> if (adata->acp3x_audio_mode == ACP3x_I2S_MODE) {
>> for (i = 0 ; i < ACP3x_DEVS ; i++)
> ^^
> There is an extra space char here as well. I guess I missed it when I
> reviewed patch 1.
>
>> platform_device_unregister(adata->pdev[i]);
>> }
>> + ret = acp3x_deinit(adata->acp3x_base);
>> + if (ret)
>> + dev_err(&pci->dev, "ACP de-init failed\n");
>> + else
>> + dev_dbg(&pci->dev, "ACP de-initialized\n");
>
> Put the printk in acp3x_deinit() itself and remove it from all the
> callers.
>
> regards,
> dan carpenter
>
next prev parent reply other threads:[~2019-11-19 12:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1574165476-24987-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com>
2019-11-19 12:11 ` [PATCH v9 1/6] ASoC: amd:Create multiple I2S platform device endpoint Ravulapati Vishnu vardhan rao
2019-11-19 12:11 ` [RESEND PATCH v9 2/6] ASoC: amd: Refactoring of DAI from DMA driver Ravulapati Vishnu vardhan rao
2019-11-19 12:11 ` [RESEND PATCH v9 3/6] ASoC: amd: Enabling I2S instance in DMA and DAI Ravulapati Vishnu vardhan rao
2019-11-19 12:11 ` [RESEND PATCH v9 4/6] ASoC: amd: add ACP3x TDM mode support Ravulapati Vishnu vardhan rao
2019-11-19 12:11 ` [RESEND PATCH v9 5/6] ASoC: amd: Handle ACP3x I2S-SP Interrupts Ravulapati Vishnu vardhan rao
2019-11-19 12:11 ` [RESEND PATCH v9 6/6] ASoC: amd: Added ACP3x system resume and runtime pm Ravulapati Vishnu vardhan rao
2019-11-19 12:35 ` Dan Carpenter
2019-11-19 12:56 ` vishnu [this message]
2019-11-19 13:34 ` Dan Carpenter
2019-11-19 17:55 ` Mark Brown
2019-11-19 14:03 ` vishnu
2019-11-19 14:10 ` Dan Carpenter
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=3321478e-de8f-2eb6-6e6f-6eb621b8434b@amd.com \
--to=vravulap@amd.com \
--cc=Akshu.Agrawal@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=Vishnuvardhanrao.Ravulapati@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=djkurtz@google.com \
--cc=gustavo@embeddedor.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=yuehaibing@huawei.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).