From: Siddharth Vadapalli <s-vadapalli@ti.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Siddharth Vadapalli <s-vadapalli@ti.com>, <lpieralisi@kernel.org>,
<kwilczynski@kernel.org>, <robh@kernel.org>,
<bhelgaas@google.com>, <helgaas@kernel.org>, <kishon@kernel.org>,
<vigneshr@ti.com>, <stable@vger.kernel.org>,
<linux-pci@vger.kernel.org>, <linux-omap@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <srk@ti.com>
Subject: Re: [PATCH v3] PCI: j721e: Fix programming sequence of "strap" settings
Date: Tue, 2 Sep 2025 10:34:51 +0530 [thread overview]
Message-ID: <08b87b5f-838b-4f40-ae90-10ded134356e@ti.com> (raw)
In-Reply-To: <7hxdcjm7evlphkldct7seytno4is7rjkx5vquvtfhpdkzxdhu6@yocrjgzciwu3>
On Mon, Sep 01, 2025 at 08:15:24PM +0530, Manivannan Sadhasivam wrote:
> On Mon, Sep 01, 2025 at 04:50:02PM GMT, Siddharth Vadapalli wrote:
> > On Mon, Sep 01, 2025 at 12:14:51PM +0530, Manivannan Sadhasivam wrote:
> > > On Mon, Sep 01, 2025 at 11:51:33AM GMT, Siddharth Vadapalli wrote:
[...]
> > > >
> > > > If I understand correctly, are you suggesting the following?
> > > >
> > > > j721e_pcie_probe()
> > > > pm_runtime_set_active()
> > > > pm_runtime_enable()
> > > > ret = j721e_pcie_ctrl_init(pcie);
> > > > /*
> > > > * PCIe Controller should be powered off here, but is there
> > > > * a way to ensure that it has been powered off?
> > > > */
> > > > => Program the strap settings and return to
> > > > j721e_pcie_probe()
> > > > /* Power on the PCIe Controller now */
> > > > ret = pm_runtime_get_sync(dev);
> > >
> > > This pm_runtime_get_sync() should be part of j721e_pcie_ctrl_init() where you
> > > do power off, program strap and power on.
> > >
> > > This should not be part of probe() as by that time, controller is already
> > > powered on. So pm_runtime_set_active() and pm_runtime_enable() should be enough
> > > to convey the state of the device to PM core.
> >
> > I have tried out the suggestion in the following manner:
> >
> > j721e_pcie_probe()
> > ...
> > pm_runtime_set_active(dev);
> > pm_runtime_enable(dev);
> > ret = j721e_pcie_ctrl_init(pcie);
> > ... within j721e_pcie_ctrl_init()
> > ret = pm_runtime_put_sync(dev);
> > /* Program Strap Settings */
> > ret = pm_runtime_get_sync(dev);
> > ...
> > ...
> > exit probe
> >
> > Since a 'pm_runtime_get_sync()' hasn't yet been invoked prior to the
> > section where 'pm_runtime_put_sync()' is invoked, it leads to a ref-count
> > underflow error at runtime. Please let me know if I am missing
> > something.
> >
>
> Doh... At the start of probe(), device PM usage_count will be 0. So we cannot
> decrement it without incrementing it.
>
> Could you try below sequence?
>
> probe()
> ...
> pm_runtime_set_active()
> pm_runtime_enable()
> j721e_pcie_ctrl_init()
> ...
> pm_runtime_get() /* Just increment usage_count */
> pm_runtime_put_sync() /* ask PM core to turn off */
> /* program strap setting */
> pm_runtime_get_sync() /* ask PM core to turn on */
> pm_runtime_put_noidle() /* balance the usage_count without
> suspending the device */
> ...
The above sequence powers off the controller at the point in time that
the strap settings are programmed. 'pm_runtime_get_sync()' is powering
on the controller afterwards. However, the 'pm_runtime_put_noidle()'
at the end is causing the controller to be powered off again leading to
a crash. Removing 'pm_runtime_put_noidle()' results in a functional
sequence.
Please consider the existing sequence prior to this patch:
probe()
...
pm_runtime_enable()
pm_runtime_get_sync() => usage_count is 1
...
exit probe
With the suggested sequence above, we have:
probe()
...
pm_runtime_set_active()
pm_runtime_enable()
j721e_pcie_ctrl_init()
...
pm_runtime_get() => usage_count is 1
pm_runtime_put_sync() => usage_count is 0
/* Controller is powered off now */
/* Strap settings are programmed */
pm_runtime_get_sync() => usage_count is 1
/* Controller is powered on now */
pm_runtime_put_noidle() => usage_count is 0
/* Controller is powered off in a while */
...
/* Crash is observed aroung this point before probe finishes */
Please let me know if the fix is to drop 'pm_runtime_put_noidle()'
from the above sequence.
Regards,
Siddharth.
next prev parent reply other threads:[~2025-09-02 5:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 9:16 [PATCH v3] PCI: j721e: Fix programming sequence of "strap" settings Siddharth Vadapalli
2025-08-31 12:45 ` Manivannan Sadhasivam
2025-09-01 4:57 ` Siddharth Vadapalli
2025-09-01 5:48 ` Manivannan Sadhasivam
2025-09-01 6:21 ` Siddharth Vadapalli
2025-09-01 6:44 ` Manivannan Sadhasivam
2025-09-01 11:20 ` Siddharth Vadapalli
2025-09-01 14:45 ` Manivannan Sadhasivam
2025-09-02 5:04 ` Siddharth Vadapalli [this message]
2025-09-03 13:21 ` Manivannan Sadhasivam
2025-09-04 6:03 ` Siddharth Vadapalli
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=08b87b5f-838b-4f40-ae90-10ded134356e@ti.com \
--to=s-vadapalli@ti.com \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=srk@ti.com \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.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).