diff mbox series

[v3,3/3] PCI: apple: Fix #PERST polarity

Message ID 20211123180636.80558-4-maz@kernel.org (mailing list archive)
State Accepted
Delegated to: Lorenzo Pieralisi
Headers show
Series PCI: apple: Assorted #PERST fixes | expand

Commit Message

Marc Zyngier Nov. 23, 2021, 6:06 p.m. UTC
Now that #PERST is properly defined as active-low in the device tree,
fix the driver to correctly drive the line indemendently of the
implied polarity.

Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
Suggested-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pci/controller/pcie-apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Luca Ceresoli Nov. 23, 2021, 9:36 p.m. UTC | #1
Hi Mark,

On 23/11/21 19:06, Marc Zyngier wrote:
> Now that #PERST is properly defined as active-low in the device tree,
> fix the driver to correctly drive the line indemendently of the
> implied polarity.
> 
> Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
> Suggested-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Thanks for quickly addressing this!

Do we need a transition path for backward compatibility with old DTs
already around? Something like this [0]. You said [1] the DT actually
used is not even the one in the kernel, thus how do we guarantee DT and
driver switch to the new polarity all at once?

[0] https://lkml.org/lkml/2021/6/24/1049
[1] https://lkml.org/lkml/2021/11/23/455

> ---
>  drivers/pci/controller/pcie-apple.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index 957960a733c4..03bc56f39be5 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -540,7 +540,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
>  	rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK);
>  
>  	/* Engage #PERST before setting up the clock */
>
> -	gpiod_set_value(reset, 0);
> +	gpiod_set_value(reset, 1);
>  
>  	ret = apple_pcie_setup_refclk(pcie, port);
>  	if (ret < 0)
> @@ -551,7 +551,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
>  
>  	/* Deassert #PERST */
>  	rmw_set(PORT_PERST_OFF, port->base + PORT_PERST);
> -	gpiod_set_value(reset, 1);
> +	gpiod_set_value(reset, 0);

Minor note: if it were me I would coalesce patches 1 and 3 together,
otherwise we are insisting on a wrong implementation (patch 1) to later
fix it all (this patch).
Marc Zyngier Nov. 24, 2021, 9:02 a.m. UTC | #2
On Tue, 23 Nov 2021 21:36:11 +0000,
Luca Ceresoli <luca@lucaceresoli.net> wrote:
> 
> Hi Mark,
> 
> On 23/11/21 19:06, Marc Zyngier wrote:
> > Now that #PERST is properly defined as active-low in the device tree,
> > fix the driver to correctly drive the line indemendently of the
> > implied polarity.
> > 
> > Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
> > Suggested-by: Pali Rohár <pali@kernel.org>
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> 
> Thanks for quickly addressing this!
> 
> Do we need a transition path for backward compatibility with old DTs
> already around? Something like this [0]. You said [1] the DT actually
> used is not even the one in the kernel, thus how do we guarantee DT and
> driver switch to the new polarity all at once?

No. As it turns out, neither u-boot nor OpenBSD (the only two other
payloads that can boot on M1) are upstreamed yet. So we're still in
that stage where we don't need to maintain backward compatibility. If
we don't get this patches merged by the end of this cycle, we will
have to revisit this though.

> 
> [0] https://lkml.org/lkml/2021/6/24/1049
> [1] https://lkml.org/lkml/2021/11/23/455
> 
> > ---
> >  drivers/pci/controller/pcie-apple.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> > index 957960a733c4..03bc56f39be5 100644
> > --- a/drivers/pci/controller/pcie-apple.c
> > +++ b/drivers/pci/controller/pcie-apple.c
> > @@ -540,7 +540,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
> >  	rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK);
> >  
> >  	/* Engage #PERST before setting up the clock */
> >
> > -	gpiod_set_value(reset, 0);
> > +	gpiod_set_value(reset, 1);
> >  
> >  	ret = apple_pcie_setup_refclk(pcie, port);
> >  	if (ret < 0)
> > @@ -551,7 +551,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
> >  
> >  	/* Deassert #PERST */
> >  	rmw_set(PORT_PERST_OFF, port->base + PORT_PERST);
> > -	gpiod_set_value(reset, 1);
> > +	gpiod_set_value(reset, 0);
> 
> Minor note: if it were me I would coalesce patches 1 and 3 together,
> otherwise we are insisting on a wrong implementation (patch 1) to later
> fix it all (this patch).

The first patch is a clear bug fix that has a direct HW impact. The
second patch is only sugar coating with zero material impact
(absolutely nothing changes in the way the HW is driven). Squashing
these two patches would be absolutely the wrong thing to do.

	M.
Luca Ceresoli Nov. 24, 2021, 9:16 a.m. UTC | #3
Hi,

On 24/11/21 10:02, Marc Zyngier wrote:
> On Tue, 23 Nov 2021 21:36:11 +0000,
> Luca Ceresoli <luca@lucaceresoli.net> wrote:
>>
>> Hi Mark,
>>
>> On 23/11/21 19:06, Marc Zyngier wrote:
>>> Now that #PERST is properly defined as active-low in the device tree,
>>> fix the driver to correctly drive the line indemendently of the
>>> implied polarity.
>>>
>>> Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
>>> Suggested-by: Pali Rohár <pali@kernel.org>
>>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>>
>> Thanks for quickly addressing this!
>>
>> Do we need a transition path for backward compatibility with old DTs
>> already around? Something like this [0]. You said [1] the DT actually
>> used is not even the one in the kernel, thus how do we guarantee DT and
>> driver switch to the new polarity all at once?
> 
> No. As it turns out, neither u-boot nor OpenBSD (the only two other
> payloads that can boot on M1) are upstreamed yet. So we're still in
> that stage where we don't need to maintain backward compatibility. If
> we don't get this patches merged by the end of this cycle, we will
> have to revisit this though.

Good news!

Reviewed-by: Luca Ceresoli <luca@lucaceresoli.net>
diff mbox series

Patch

diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 957960a733c4..03bc56f39be5 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -540,7 +540,7 @@  static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK);
 
 	/* Engage #PERST before setting up the clock */
-	gpiod_set_value(reset, 0);
+	gpiod_set_value(reset, 1);
 
 	ret = apple_pcie_setup_refclk(pcie, port);
 	if (ret < 0)
@@ -551,7 +551,7 @@  static int apple_pcie_setup_port(struct apple_pcie *pcie,
 
 	/* Deassert #PERST */
 	rmw_set(PORT_PERST_OFF, port->base + PORT_PERST);
-	gpiod_set_value(reset, 1);
+	gpiod_set_value(reset, 0);
 
 	/* Wait for 100ms after #PERST deassertion (PCIe r2.0, 6.6.1) */
 	msleep(100);