All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@mailbox.org>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: linux-pci@vger.kernel.org,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v4 5/6] PCI: dwc: rcar-gen4: Handle PERST via reset subsystem
Date: Mon, 21 Sep 2026 18:31:22 +0200	[thread overview]
Message-ID: <67ab9f01-069e-4010-8f5e-7f65bf30ebd6@mailbox.org> (raw)
In-Reply-To: <zwdqspl2uno35uffgzsel57ed2umpejgfeqrkwvxiqd2pgfpm6@h6w3qsgc6rny>

On 9/21/26 5:46 PM, Manivannan Sadhasivam wrote:

Hello Manivannan,

>> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
>> @@ -99,6 +99,7 @@ struct rcar_gen4_pcie {
>>   	void __iomem *base;
>>   	void __iomem *phy_base;
>>   	struct platform_device *pdev;
>> +	struct reset_control *perst;
>>   	const struct rcar_gen4_pcie_drvdata *drvdata;
>>   };
>>   #define to_rcar_gen4_pcie(_dw)	container_of(_dw, struct rcar_gen4_pcie, dw)
>> @@ -317,12 +318,27 @@ static void rcar_gen4_pcie_unprepare(struct rcar_gen4_pcie *rcar)
>>   
>>   static int rcar_gen4_pcie_get_resources(struct rcar_gen4_pcie *rcar)
>>   {
>> +	struct device *dev = rcar->dw.dev;
>> +	struct device_node *root_port;
>> +
>>   	rcar->phy_base = devm_platform_ioremap_resource_byname(rcar->pdev, "phy");
>>   	if (IS_ERR(rcar->phy_base))
>>   		return PTR_ERR(rcar->phy_base);
>>   
>> +	root_port = of_get_next_available_child(dev->of_node, NULL);
>> +	if (root_port) {
>> +		rcar->perst = of_reset_control_get_optional_exclusive(root_port, "perst");
>> +		of_node_put(root_port);
>> +		if (IS_ERR(rcar->perst))
>> +			return dev_err_probe(dev, PTR_ERR(rcar->perst), "Failed to get PERST#\n");
>> +	} else {
>> +		rcar->perst = NULL;
> 
> 'rcar->perst' is NULL by default.

Indeed.

>> +	}
>> +
>>   	/* Renesas-specific registers */
>>   	rcar->base = devm_platform_ioremap_resource_byname(rcar->pdev, "app");
>> +	if (IS_ERR(rcar->base))
>> +		reset_control_put(rcar->perst);
>>   
>>   	return PTR_ERR_OR_ZERO(rcar->base);
>>   }
>> @@ -494,6 +510,22 @@ static int rcar_gen4_pcie_enable_device(struct pci_host_bridge *bridge,
>>   	return 0;
>>   }
>>   
>> +static void rcar_gen4_pcie_host_perst_assert(struct dw_pcie_rp *pp, bool assert)
>> +{
>> +	struct dw_pcie *dw = to_dw_pcie_from_pp(pp);
>> +	struct rcar_gen4_pcie *rcar = to_rcar_gen4_pcie(dw);
>> +
>> +	gpiod_set_value_cansleep(dw->pe_rst, assert);
>> +
>> +	if (!rcar->perst)
>> +		return;
>> +
>> +	if (assert)
>> +		reset_control_assert(rcar->perst);
>> +	else
>> +		reset_control_deassert(rcar->perst);
> 
> So the controller will only have one form of PERST# implemented at a time. Even
> though this code is technically correct, it also gives an impression that both
> form could co-exist.
> 
> So I'd recommend using:
> 
>          if (dw->pe_rst) {
>                  gpiod_set_value_cansleep(dw->pe_rst, assert);
>          } else {
>                  if (assert)
>                          reset_control_assert(rcar->perst);
>                  else
>                          reset_control_deassert(rcar->perst);
>          }
> 
> to makes it clear that only one form of PERST# is supported.
> 
> I'll implement both of these changes while applying.

Please do. Thank you !

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2026-09-21 16:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05 21:26 [PATCH v4 0/6] PCI: dwc: rcar-gen4: Add support for R-Car X5H PCIe4 Marek Vasut
2026-09-05 21:26 ` [PATCH v4 1/6] dt-bindings: PCI: rcar-gen4-pci-host: Add R-Car X5H PCIe4 compatible Marek Vasut
2026-09-05 21:36   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 2/6] PCI: dwc: rcar-gen4: Rework rcar_gen4_pcie_drvdata .additional_common_init into .init Marek Vasut
2026-09-05 21:33   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 3/6] PCI: dwc: rcar-gen4: Add .deinit callback Marek Vasut
2026-09-05 21:38   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 4/6] PCI: dwc: rcar-gen4: Split .start_link into ltssm_control and speed_control Marek Vasut
2026-09-05 21:32   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 5/6] PCI: dwc: rcar-gen4: Handle PERST via reset subsystem Marek Vasut
2026-09-05 21:38   ` sashiko-bot
2026-09-21 15:46   ` Manivannan Sadhasivam
2026-09-21 16:31     ` Marek Vasut [this message]
2026-09-05 21:26 ` [PATCH v4 6/6] PCI: dwc: rcar-gen4: Add support for R-Car X5H PCIe4 Marek Vasut
2026-09-05 21:40   ` sashiko-bot
2026-09-21 16:03   ` Manivannan Sadhasivam
2026-09-21 20:24     ` Marek Vasut

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=67ab9f01-069e-4010-8f5e-7f65bf30ebd6@mailbox.org \
    --to=marek.vasut@mailbox.org \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=krzk+dt@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=robh@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.