public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Siddharth Vadapalli <s-vadapalli@ti.com>
Cc: linux-pci@vger.kernel.org, ryder.lee@mediatek.com,
	jianjun.wang@mediatek.com, lpieralisi@kernel.org, kw@linux.com,
	robh@kernel.org, bhelgaas@google.com, p.zabel@pengutronix.de,
	matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kernel@collabora.com,
	wenst@chromium.org, nfraprado@collabora.com
Subject: Re: [PATCH v2] PCI: mediatek-gen3: Assert MAC reset only if PHY reset also present
Date: Fri, 1 Mar 2024 10:06:33 +0100	[thread overview]
Message-ID: <2b2effdd-0b9d-40fd-a88d-ab364f2b0668@collabora.com> (raw)
In-Reply-To: <a55428b8-27b3-42f7-8154-ccc7dde469df@ti.com>

Il 01/03/24 07:42, Siddharth Vadapalli ha scritto:
> On Thu, Feb 29, 2024 at 10:24:49AM +0100, AngeloGioacchino Del Regno wrote:
>> Some SoCs have two PCI-Express controllers: in the case of MT8195,
>> one of them is using a dedicated PHY, but the other uses a combo PHY
>> that is shared with USB and in that case the PHY cannot be reset
>> from the PCIe driver, or USB functionality will be unable to resume.
>>
>> Resetting the PCIe MAC without also resetting the PHY will result in
>> a full system lockup at PCIe resume time and the only option to
>> resume operation is to hard reboot the system (with a PMIC cut-off).
>>
>> To resolve this issue, check if we've got both a PHY and a MAC reset
>> and, if not, never assert resets at PM suspend time: in that case,
>> the link is still getting powered down as both the clocks and the
>> power domains will go down anyway.
>>
>> Fixes: d537dc125f07 ("PCI: mediatek-gen3: Add system PM support")
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> ---
>>
>> Changes in v2:
>>   - Rebased over next-20240229
>>
>>   drivers/pci/controller/pcie-mediatek-gen3.c | 25 ++++++++++++++-------
>>   1 file changed, 17 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
>> index 975b3024fb08..99b5d7a49be1 100644
>> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
>> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
>> @@ -874,17 +874,26 @@ static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie)
>>   	return err;
>>   }
>>   
>> -static void mtk_pcie_power_down(struct mtk_gen3_pcie *pcie)
>> +static void mtk_pcie_power_down(struct mtk_gen3_pcie *pcie, bool is_suspend)
>>   {
>> +	bool suspend_reset_supported = pcie->mac_reset && pcie->phy_reset;
>> +
>>   	clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks);
>>   
>>   	pm_runtime_put_sync(pcie->dev);
>>   	pm_runtime_disable(pcie->dev);
>> -	reset_control_assert(pcie->mac_reset);
>> +
>> +	/*
>> +	 * Assert MAC reset only if we also got a PHY reset, otherwise
>> +	 * the system will lockup at PM resume time.
>> +	 */
>> +	if (is_suspend && suspend_reset_supported)
>> +		reset_control_assert(pcie->mac_reset);
>>   
>>   	phy_power_off(pcie->phy);
>>   	phy_exit(pcie->phy);
> 
> Wouldn't this power off the shared PHY? Or will the PHY driver make this
> NO-OP if the PHY is shared, in which case the above two statements could
> be combined with the other statements in the:
> if (is_suspend && suspend_reset_supported)
> condition to get a single block of code that also combines the
> reset_control_assert(pcie->phy_reset)
> present below.
> 

No, that'd be fine:

static int mtk_phy_power_off(struct phy *phy)
{
	struct mtk_phy_instance *instance = phy_get_drvdata(phy);
	struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent);

	if (instance->type == PHY_TYPE_USB2)
		u2_phy_instance_power_off(tphy, instance);
	else if (instance->type == PHY_TYPE_PCIE)
		pcie_phy_instance_power_off(tphy, instance);

	return 0;
}

...it's two different PHY instances that we're dealing with, here :-)

Cheers,
Angelo

>> -	reset_control_assert(pcie->phy_reset);
>> +	if (is_suspend && suspend_reset_supported)
>> +		reset_control_assert(pcie->phy_reset);
>>   }
>>   
> ...
> 
> Regards,
> Siddharth.



  reply	other threads:[~2024-03-01  9:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29  9:24 [PATCH v2] PCI: mediatek-gen3: Assert MAC reset only if PHY reset also present AngeloGioacchino Del Regno
2024-02-29 16:20 ` Nícolas F. R. A. Prado
2024-03-01  2:48 ` Jianjun Wang (王建军)
2024-03-06  8:50   ` AngeloGioacchino Del Regno
2024-03-08  9:44     ` Jianjun Wang (王建军)
2024-03-08 13:02       ` AngeloGioacchino Del Regno
2024-03-13  3:33         ` Jianjun Wang (王建军)
2024-03-01  6:42 ` Siddharth Vadapalli
2024-03-01  9:06   ` AngeloGioacchino Del Regno [this message]
2024-03-01  9:55     ` 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=2b2effdd-0b9d-40fd-a88d-ab364f2b0668@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=bhelgaas@google.com \
    --cc=jianjun.wang@mediatek.com \
    --cc=kernel@collabora.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nfraprado@collabora.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=ryder.lee@mediatek.com \
    --cc=s-vadapalli@ti.com \
    --cc=wenst@chromium.org \
    /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