linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: mediatek: Verify whether the free_ck clock is ungated or not
@ 2021-04-29 13:47 Amey Narkhede
  2021-04-29 22:38 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Amey Narkhede @ 2021-04-29 13:47 UTC (permalink / raw)
  To: Ryder Lee
  Cc: Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas, Philipp Zabel,
	Matthias Brugger, linux-kernel, linux-pci, linux-mediatek,
	linux-arm-kernel, Amey Narkhede

Verify that the free_ck clock is ungated on device resume
by checking return value of clk_prepare_enable().

Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
---
 drivers/pci/controller/pcie-mediatek.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
index 23548b517..9b13214bf 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -1154,11 +1154,14 @@ static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev)
 {
 	struct mtk_pcie *pcie = dev_get_drvdata(dev);
 	struct mtk_pcie_port *port, *tmp;
+	int ret;

 	if (list_empty(&pcie->ports))
 		return 0;

-	clk_prepare_enable(pcie->free_ck);
+	ret = clk_prepare_enable(pcie->free_ck);
+	if (ret)
+		return ret;

 	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
 		mtk_pcie_enable_port(port);
--
2.31.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: mediatek: Verify whether the free_ck clock is ungated or not
  2021-04-29 13:47 [PATCH] PCI: mediatek: Verify whether the free_ck clock is ungated or not Amey Narkhede
@ 2021-04-29 22:38 ` Bjorn Helgaas
  2021-04-30  6:43   ` Amey Narkhede
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2021-04-29 22:38 UTC (permalink / raw)
  To: Amey Narkhede
  Cc: Ryder Lee, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas,
	Philipp Zabel, Matthias Brugger, linux-kernel, linux-pci,
	linux-mediatek, linux-arm-kernel

Can you make the subject say something at a higher level instead of
just paraphrasing the C code?  I'm guessing this means resume will now
fail if the clock isn't turned on?

On Thu, Apr 29, 2021 at 07:17:49PM +0530, Amey Narkhede wrote:
> Verify that the free_ck clock is ungated on device resume
> by checking return value of clk_prepare_enable().

Also the commit log -- this doesn't say anything more than the code
itself.  Did you find this by tripping over it?  Or just by code
inspection?  I guess without the check, we continue on and try to
resume, but accesses to PCI devices fail and maybe return ~0 data or
cause machine checks or something?

> Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
> ---
>  drivers/pci/controller/pcie-mediatek.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 23548b517..9b13214bf 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -1154,11 +1154,14 @@ static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev)
>  {
>  	struct mtk_pcie *pcie = dev_get_drvdata(dev);
>  	struct mtk_pcie_port *port, *tmp;
> +	int ret;
> 
>  	if (list_empty(&pcie->ports))
>  		return 0;
> 
> -	clk_prepare_enable(pcie->free_ck);
> +	ret = clk_prepare_enable(pcie->free_ck);
> +	if (ret)
> +		return ret;

Most callers print an error message when clk_prepare_enable() fails.

>  	list_for_each_entry_safe(port, tmp, &pcie->ports, list)
>  		mtk_pcie_enable_port(port);
> --
> 2.31.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: mediatek: Verify whether the free_ck clock is ungated or not
  2021-04-29 22:38 ` Bjorn Helgaas
@ 2021-04-30  6:43   ` Amey Narkhede
  0 siblings, 0 replies; 3+ messages in thread
From: Amey Narkhede @ 2021-04-30  6:43 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Bjorn Helgaas, Ryder Lee, lorenzo.pieralisi, Rob Herring,
	Philipp Zabel, Matthias Brugger, linux-kernel, linux-pci,
	linux-mediatek, linux-arm-kernel

On 21/04/29 05:38PM, Bjorn Helgaas wrote:
> Can you make the subject say something at a higher level instead of
> just paraphrasing the C code?  I'm guessing this means resume will now
> fail if the clock isn't turned on?
>
> On Thu, Apr 29, 2021 at 07:17:49PM +0530, Amey Narkhede wrote:
> > Verify that the free_ck clock is ungated on device resume
> > by checking return value of clk_prepare_enable().
>
> Also the commit log -- this doesn't say anything more than the code
> itself.  Did you find this by tripping over it?  Or just by code
> inspection?  I guess without the check, we continue on and try to
> resume, but accesses to PCI devices fail and maybe return ~0 data or
> cause machine checks or something?
>
I found this with code inspection. Sorry for the unclear commit
messsage. I'll try to clarify it in v2.
> > Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
> > ---
> >  drivers/pci/controller/pcie-mediatek.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> > index 23548b517..9b13214bf 100644
> > --- a/drivers/pci/controller/pcie-mediatek.c
> > +++ b/drivers/pci/controller/pcie-mediatek.c
> > @@ -1154,11 +1154,14 @@ static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev)
> >  {
> >  	struct mtk_pcie *pcie = dev_get_drvdata(dev);
> >  	struct mtk_pcie_port *port, *tmp;
> > +	int ret;
> >
> >  	if (list_empty(&pcie->ports))
> >  		return 0;
> >
> > -	clk_prepare_enable(pcie->free_ck);
> > +	ret = clk_prepare_enable(pcie->free_ck);
> > +	if (ret)
> > +		return ret;
>
> Most callers print an error message when clk_prepare_enable() fails.
>
[...]
I'll update this in v2.

Thanks,
Amey

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-30  6:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 13:47 [PATCH] PCI: mediatek: Verify whether the free_ck clock is ungated or not Amey Narkhede
2021-04-29 22:38 ` Bjorn Helgaas
2021-04-30  6:43   ` Amey Narkhede

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).