DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] staging: mt7621-pci: don't return if get gpio fails
@ 2020-03-19 16:14 Sergio Paracuellos
  2020-03-20 14:30 ` Greg Ungerer
  0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2020-03-19 16:14 UTC (permalink / raw)
  To: gregkh; +Cc: neil, driverdev-devel, gerg

In some platforms gpio's are not used for reset but
for other purposes. Because of that when we try to
get them are valid gpio's but are already assigned
to do other function. To avoid those kind of problems
in those platforms just notice the fail in the kernel
but continue doing normal boot.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c
index 2a01645162a5..d6fc8a08c9bd 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -363,10 +363,8 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
 
 	port->gpio_rst = devm_gpiod_get_index_optional(dev, "reset", slot,
 						       GPIOD_OUT_LOW);
-	if (IS_ERR(port->gpio_rst)) {
-		dev_err(dev, "Failed to get GPIO for PCIe%d\n", slot);
-		return PTR_ERR(port->gpio_rst);
-	}
+	if (IS_ERR(port->gpio_rst))
+		dev_notice(dev, "Failed to get GPIO for PCIe%d\n", slot);
 
 	port->slot = slot;
 	port->pcie = pcie;
-- 
2.25.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: mt7621-pci: don't return if get gpio fails
  2020-03-19 16:14 [PATCH] staging: mt7621-pci: don't return if get gpio fails Sergio Paracuellos
@ 2020-03-20 14:30 ` Greg Ungerer
  2020-03-20 14:38   ` Sergio Paracuellos
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Ungerer @ 2020-03-20 14:30 UTC (permalink / raw)
  To: Sergio Paracuellos, gregkh; +Cc: neil, driverdev-devel

Hi Sergio,

On 20/3/20 2:14 am, Sergio Paracuellos wrote:
> In some platforms gpio's are not used for reset but
> for other purposes. Because of that when we try to
> get them are valid gpio's but are already assigned
> to do other function. To avoid those kind of problems
> in those platforms just notice the fail in the kernel
> but continue doing normal boot.
> 
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>   drivers/staging/mt7621-pci/pci-mt7621.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c
> index 2a01645162a5..d6fc8a08c9bd 100644
> --- a/drivers/staging/mt7621-pci/pci-mt7621.c
> +++ b/drivers/staging/mt7621-pci/pci-mt7621.c
> @@ -363,10 +363,8 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
>   
>   	port->gpio_rst = devm_gpiod_get_index_optional(dev, "reset", slot,
>   						       GPIOD_OUT_LOW);
> -	if (IS_ERR(port->gpio_rst)) {
> -		dev_err(dev, "Failed to get GPIO for PCIe%d\n", slot);
> -		return PTR_ERR(port->gpio_rst);
> -	}
> +	if (IS_ERR(port->gpio_rst))
> +		dev_notice(dev, "Failed to get GPIO for PCIe%d\n", slot);
>   
>   	port->slot = slot;
>   	port->pcie = pcie;

Even with this fix in place I still get a dump on boot:

...
rt2880-pinmux pinctrl: pcie is already enabled
mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
mt7621-pci 1e140000.pcie: Failed to get GPIO for PCIe1
mt7621-pci 1e140000.pcie: Failed to get GPIO for PCIe2
gpiod_set_value: invalid GPIO (errorpointer)
gpiod_set_value: invalid GPIO (errorpointer)
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
gpiod_set_value: invalid GPIO (errorpointer)
gpiod_set_value: invalid GPIO (errorpointer)
mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: PCIE0 enabled
mt7621-pci 1e140000.pcie: PCI coherence region base: 0x60000000, mask/settings: 0xf0000002
mt7621-pci 1e140000.pcie: PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io  0xffffffff]
pci_bus 0000:00: root bus resource [mem 0x60000000-0x6fffffff]
pci_bus 0000:00: root bus resource [bus 00-ff]
pci 0000:00:00.0: [0e8d:0801] type 01 class 0x060400
pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x7fffffff]
pci 0000:00:00.0: reg 0x14: [mem 0x00000000-0x0000ffff]
pci 0000:00:00.0: supports D1
pci 0000:00:00.0: PME# supported from D0 D1 D3hot
pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci 0000:01:00.0: [168c:003c] type 00 class 0x028000
pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x001fffff 64bit]
pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0000ffff pref]
pci 0000:01:00.0: supports D1 D2
pci 0000:00:00.0: PCI bridge to [bus 01-ff]
pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff]
pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
pci 0000:00:00.0: BAR 0: no space for [mem size 0x80000000]
pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x80000000]
pci 0000:00:00.0: BAR 8: assigned [mem 0x60000000-0x601fffff]
pci 0000:00:00.0: BAR 9: assigned [mem 0x60200000-0x602fffff pref]
pci 0000:00:00.0: BAR 1: assigned [mem 0x60300000-0x6030ffff]
pci 0000:00:00.0: BAR 7: no space for [io  size 0x1000]
pci 0000:00:00.0: BAR 7: failed to assign [io  size 0x1000]
pci 0000:01:00.0: BAR 0: assigned [mem 0x60000000-0x601fffff 64bit]
pci 0000:01:00.0: BAR 6: assigned [mem 0x60200000-0x6020ffff pref]
pci 0000:00:00.0: PCI bridge to [bus 01]
pci 0000:00:00.0:   bridge window [mem 0x60000000-0x601fffff]
pci 0000:00:00.0:   bridge window [mem 0x60200000-0x602fffff pref]
pcieport 0000:00:00.0: of_irq_parse_pci: failed with rc=-22
pcieport 0000:00:00.0: enabling device (0004 -> 0006)
CPU 1 Unable to handle kernel paging request at virtual address fffffff0, epc == 8039c7b0, ra == 804fe0a0
Oops[#1]:
CPU: 1 PID: 103 Comm: kworker/1:1 Not tainted 5.6.0-rc3-00180-gc15e7f072288-dirty #5
Workqueue: events deferred_probe_work_func
$ 0   : 00000000 00000001 82051e84 00000001
$ 4   : fffffff0 00000001 00000000 803a0000
$ 8   : 00000024 ffffffff 00000001 302e3030
$12   : 00000000 8fd6dbd8 ffffffff 00000020
$16   : 82051e80 820d4250 00000000 8fd6dcd0
$20   : 820d41e0 809a0000 820d4228 8fd47e10
$24   : 00000000 00000020
$28   : 8fd6c000 8fd6dc70 8fd6dcf8 804fe0a0
Hi    : 00000125
Lo    : 122f2000
epc   : 8039c7b0 gpiod_free+0x14/0x6c
ra    : 804fe0a0 mt7621_pci_probe+0x678/0xc68
Status: 1100fc03        KERNEL EXL IE
Cause : 00800008 (ExcCode 02)
BadVA : fffffff0
PrId  : 0001992f (MIPS 1004Kc)
Modules linked in:
Process kworker/1:1 (pid: 103, threadinfo=(ptrval), task=(ptrval), tls=00000000)
Stack : 820d4250 809e2aa0 82051880 820d4250 82051e80 804fe0a0 1e160000 00000001
         60000000 00000000 f0000002 00000000 00000000 809a0000 8fd47e10 808d63d4
         80930000 808d6260 808d0000 808d61fc 808c0000 8fd47e10 808d6208 808d0000
         8fd6dcd0 8fd6dcd0 809e2aa0 809db510 809db510 00000006 00000001 00000000
         00000000 00000000 01000000 1e1440ff 00000000 00000000 1e160000 00000000
         ...
Call Trace:
[<8039c7b0>] gpiod_free+0x14/0x6c
[<804fe0a0>] mt7621_pci_probe+0x678/0xc68
[<80402ab8>] platform_drv_probe+0x40/0x94
[<80400a74>] really_probe+0x104/0x364
[<803feb74>] bus_for_each_drv+0x84/0xdc
[<80400924>] __device_attach+0xdc/0x120
[<803ffb5c>] bus_probe_device+0xa0/0xbc
[<80400124>] deferred_probe_work_func+0x7c/0xbc
[<800420e8>] process_one_work+0x230/0x450
[<80042638>] worker_thread+0x330/0x5fc
[<80048eb0>] kthread+0x12c/0x134
[<80007438>] ret_from_kernel_thread+0x14/0x1c
Code: 27bdffe8  afb00010  afbf0014 <8c830000> 10600005  00808025  0c0e6efb  00000000  14400007

---[ end trace b050393bd02cbb28 ]---


If however I remove the gpio 7 and 8 reset entries from the devicetree then I can boot up.
I see two cases on boot, one successfully probes the PCI bus, and seems to work:

...
rt2880-pinmux pinctrl: pcie is already enabled
mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: PCIE0 enabled
mt7621-pci 1e140000.pcie: PCI coherence region base: 0x60000000, mask/settings: 0xf0000002
mt7621-pci 1e140000.pcie: PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io  0xffffffff]
pci_bus 0000:00: root bus resource [mem 0x60000000-0x6fffffff]
pci_bus 0000:00: root bus resource [bus 00-ff]
pci 0000:00:00.0: [0e8d:0801] type 01 class 0x060400
pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x7fffffff]
pci 0000:00:00.0: reg 0x14: [mem 0x00000000-0x0000ffff]
pci 0000:00:00.0: supports D1
pci 0000:00:00.0: PME# supported from D0 D1 D3hot
pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci 0000:01:00.0: [168c:003c] type 00 class 0x028000
pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x001fffff 64bit]
pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0000ffff pref]
pci 0000:01:00.0: supports D1 D2
pci 0000:00:00.0: PCI bridge to [bus 01-ff]
pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff]
pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
pci 0000:00:00.0: BAR 0: no space for [mem size 0x80000000]
pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x80000000]
pci 0000:00:00.0: BAR 8: assigned [mem 0x60000000-0x601fffff]
pci 0000:00:00.0: BAR 9: assigned [mem 0x60200000-0x602fffff pref]
pci 0000:00:00.0: BAR 1: assigned [mem 0x60300000-0x6030ffff]
pci 0000:00:00.0: BAR 7: no space for [io  size 0x1000]
pci 0000:00:00.0: BAR 7: failed to assign [io  size 0x1000]
pci 0000:01:00.0: BAR 0: assigned [mem 0x60000000-0x601fffff 64bit]
pci 0000:01:00.0: BAR 6: assigned [mem 0x60200000-0x6020ffff pref]
pci 0000:00:00.0: PCI bridge to [bus 01]
pci 0000:00:00.0:   bridge window [mem 0x60000000-0x601fffff]
pci 0000:00:00.0:   bridge window [mem 0x60200000-0x602fffff pref]
pcieport 0000:00:00.0: of_irq_parse_pci: failed with rc=-22
pcieport 0000:00:00.0: enabling device (0004 -> 0006)
...

The other case does not probe successfully (but still boots up all the way):

...
rt2880-pinmux pinctrl: pcie is already enabled
mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
mt7621-pci 1e140000.pcie: Nothing is connected in virtual bridges. Exiting..
...

It is probably 50:50 on any boot whether it will probe pci successfully or
fail to probe it.

BTW, this is with the patch here applied:
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142472.html

Regards
Greg



_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: mt7621-pci: don't return if get gpio fails
  2020-03-20 14:30 ` Greg Ungerer
@ 2020-03-20 14:38   ` Sergio Paracuellos
  2020-03-20 15:08     ` Greg Ungerer
  0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2020-03-20 14:38 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: NeilBrown, Greg KH, driverdev-devel

Hi Greg,

On Fri, Mar 20, 2020 at 3:30 PM Greg Ungerer <gerg@kernel.org> wrote:
>
> Hi Sergio,
>
> On 20/3/20 2:14 am, Sergio Paracuellos wrote:
> > In some platforms gpio's are not used for reset but
> > for other purposes. Because of that when we try to
> > get them are valid gpio's but are already assigned
> > to do other function. To avoid those kind of problems
> > in those platforms just notice the fail in the kernel
> > but continue doing normal boot.
> >
> > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> > ---
> >   drivers/staging/mt7621-pci/pci-mt7621.c | 6 ++----
> >   1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c
> > index 2a01645162a5..d6fc8a08c9bd 100644
> > --- a/drivers/staging/mt7621-pci/pci-mt7621.c
> > +++ b/drivers/staging/mt7621-pci/pci-mt7621.c
> > @@ -363,10 +363,8 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
> >
> >       port->gpio_rst = devm_gpiod_get_index_optional(dev, "reset", slot,
> >                                                      GPIOD_OUT_LOW);
> > -     if (IS_ERR(port->gpio_rst)) {
> > -             dev_err(dev, "Failed to get GPIO for PCIe%d\n", slot);
> > -             return PTR_ERR(port->gpio_rst);
> > -     }
> > +     if (IS_ERR(port->gpio_rst))
> > +             dev_notice(dev, "Failed to get GPIO for PCIe%d\n", slot);
> >
> >       port->slot = slot;
> >       port->pcie = pcie;
>
> Even with this fix in place I still get a dump on boot:
>
> ...
> rt2880-pinmux pinctrl: pcie is already enabled
> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> mt7621-pci 1e140000.pcie: Failed to get GPIO for PCIe1
> mt7621-pci 1e140000.pcie: Failed to get GPIO for PCIe2
> gpiod_set_value: invalid GPIO (errorpointer)
> gpiod_set_value: invalid GPIO (errorpointer)
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> gpiod_set_value: invalid GPIO (errorpointer)
> gpiod_set_value: invalid GPIO (errorpointer)
> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: PCIE0 enabled
> mt7621-pci 1e140000.pcie: PCI coherence region base: 0x60000000, mask/settings: 0xf0000002
> mt7621-pci 1e140000.pcie: PCI host bridge to bus 0000:00
> pci_bus 0000:00: root bus resource [io  0xffffffff]
> pci_bus 0000:00: root bus resource [mem 0x60000000-0x6fffffff]
> pci_bus 0000:00: root bus resource [bus 00-ff]
> pci 0000:00:00.0: [0e8d:0801] type 01 class 0x060400
> pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x7fffffff]
> pci 0000:00:00.0: reg 0x14: [mem 0x00000000-0x0000ffff]
> pci 0000:00:00.0: supports D1
> pci 0000:00:00.0: PME# supported from D0 D1 D3hot
> pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
> pci 0000:01:00.0: [168c:003c] type 00 class 0x028000
> pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x001fffff 64bit]
> pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0000ffff pref]
> pci 0000:01:00.0: supports D1 D2
> pci 0000:00:00.0: PCI bridge to [bus 01-ff]
> pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
> pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff]
> pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
> pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
> pci 0000:00:00.0: BAR 0: no space for [mem size 0x80000000]
> pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x80000000]
> pci 0000:00:00.0: BAR 8: assigned [mem 0x60000000-0x601fffff]
> pci 0000:00:00.0: BAR 9: assigned [mem 0x60200000-0x602fffff pref]
> pci 0000:00:00.0: BAR 1: assigned [mem 0x60300000-0x6030ffff]
> pci 0000:00:00.0: BAR 7: no space for [io  size 0x1000]
> pci 0000:00:00.0: BAR 7: failed to assign [io  size 0x1000]
> pci 0000:01:00.0: BAR 0: assigned [mem 0x60000000-0x601fffff 64bit]
> pci 0000:01:00.0: BAR 6: assigned [mem 0x60200000-0x6020ffff pref]
> pci 0000:00:00.0: PCI bridge to [bus 01]
> pci 0000:00:00.0:   bridge window [mem 0x60000000-0x601fffff]
> pci 0000:00:00.0:   bridge window [mem 0x60200000-0x602fffff pref]
> pcieport 0000:00:00.0: of_irq_parse_pci: failed with rc=-22
> pcieport 0000:00:00.0: enabling device (0004 -> 0006)
> CPU 1 Unable to handle kernel paging request at virtual address fffffff0, epc == 8039c7b0, ra == 804fe0a0
> Oops[#1]:
> CPU: 1 PID: 103 Comm: kworker/1:1 Not tainted 5.6.0-rc3-00180-gc15e7f072288-dirty #5
> Workqueue: events deferred_probe_work_func
> $ 0   : 00000000 00000001 82051e84 00000001
> $ 4   : fffffff0 00000001 00000000 803a0000
> $ 8   : 00000024 ffffffff 00000001 302e3030
> $12   : 00000000 8fd6dbd8 ffffffff 00000020
> $16   : 82051e80 820d4250 00000000 8fd6dcd0
> $20   : 820d41e0 809a0000 820d4228 8fd47e10
> $24   : 00000000 00000020
> $28   : 8fd6c000 8fd6dc70 8fd6dcf8 804fe0a0
> Hi    : 00000125
> Lo    : 122f2000
> epc   : 8039c7b0 gpiod_free+0x14/0x6c
> ra    : 804fe0a0 mt7621_pci_probe+0x678/0xc68
> Status: 1100fc03        KERNEL EXL IE
> Cause : 00800008 (ExcCode 02)
> BadVA : fffffff0
> PrId  : 0001992f (MIPS 1004Kc)
> Modules linked in:
> Process kworker/1:1 (pid: 103, threadinfo=(ptrval), task=(ptrval), tls=00000000)
> Stack : 820d4250 809e2aa0 82051880 820d4250 82051e80 804fe0a0 1e160000 00000001
>          60000000 00000000 f0000002 00000000 00000000 809a0000 8fd47e10 808d63d4
>          80930000 808d6260 808d0000 808d61fc 808c0000 8fd47e10 808d6208 808d0000
>          8fd6dcd0 8fd6dcd0 809e2aa0 809db510 809db510 00000006 00000001 00000000
>          00000000 00000000 01000000 1e1440ff 00000000 00000000 1e160000 00000000
>          ...
> Call Trace:
> [<8039c7b0>] gpiod_free+0x14/0x6c
> [<804fe0a0>] mt7621_pci_probe+0x678/0xc68
> [<80402ab8>] platform_drv_probe+0x40/0x94
> [<80400a74>] really_probe+0x104/0x364
> [<803feb74>] bus_for_each_drv+0x84/0xdc
> [<80400924>] __device_attach+0xdc/0x120
> [<803ffb5c>] bus_probe_device+0xa0/0xbc
> [<80400124>] deferred_probe_work_func+0x7c/0xbc
> [<800420e8>] process_one_work+0x230/0x450
> [<80042638>] worker_thread+0x330/0x5fc
> [<80048eb0>] kthread+0x12c/0x134
> [<80007438>] ret_from_kernel_thread+0x14/0x1c
> Code: 27bdffe8  afb00010  afbf0014 <8c830000> 10600005  00808025  0c0e6efb  00000000  14400007
>
> ---[ end trace b050393bd02cbb28 ]---
>
>
> If however I remove the gpio 7 and 8 reset entries from the devicetree then I can boot up.
> I see two cases on boot, one successfully probes the PCI bus, and seems to work:
>
> ...
> rt2880-pinmux pinctrl: pcie is already enabled
> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: PCIE0 enabled
> mt7621-pci 1e140000.pcie: PCI coherence region base: 0x60000000, mask/settings: 0xf0000002
> mt7621-pci 1e140000.pcie: PCI host bridge to bus 0000:00
> pci_bus 0000:00: root bus resource [io  0xffffffff]
> pci_bus 0000:00: root bus resource [mem 0x60000000-0x6fffffff]
> pci_bus 0000:00: root bus resource [bus 00-ff]
> pci 0000:00:00.0: [0e8d:0801] type 01 class 0x060400
> pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x7fffffff]
> pci 0000:00:00.0: reg 0x14: [mem 0x00000000-0x0000ffff]
> pci 0000:00:00.0: supports D1
> pci 0000:00:00.0: PME# supported from D0 D1 D3hot
> pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
> pci 0000:01:00.0: [168c:003c] type 00 class 0x028000
> pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x001fffff 64bit]
> pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0000ffff pref]
> pci 0000:01:00.0: supports D1 D2
> pci 0000:00:00.0: PCI bridge to [bus 01-ff]
> pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
> pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff]
> pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff pref]
> pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
> pci 0000:00:00.0: BAR 0: no space for [mem size 0x80000000]
> pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x80000000]
> pci 0000:00:00.0: BAR 8: assigned [mem 0x60000000-0x601fffff]
> pci 0000:00:00.0: BAR 9: assigned [mem 0x60200000-0x602fffff pref]
> pci 0000:00:00.0: BAR 1: assigned [mem 0x60300000-0x6030ffff]
> pci 0000:00:00.0: BAR 7: no space for [io  size 0x1000]
> pci 0000:00:00.0: BAR 7: failed to assign [io  size 0x1000]
> pci 0000:01:00.0: BAR 0: assigned [mem 0x60000000-0x601fffff 64bit]
> pci 0000:01:00.0: BAR 6: assigned [mem 0x60200000-0x6020ffff pref]
> pci 0000:00:00.0: PCI bridge to [bus 01]
> pci 0000:00:00.0:   bridge window [mem 0x60000000-0x601fffff]
> pci 0000:00:00.0:   bridge window [mem 0x60200000-0x602fffff pref]
> pcieport 0000:00:00.0: of_irq_parse_pci: failed with rc=-22
> pcieport 0000:00:00.0: enabling device (0004 -> 0006)
> ...
>
> The other case does not probe successfully (but still boots up all the way):
>
> ...
> rt2880-pinmux pinctrl: pcie is already enabled
> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
> mt7621-pci 1e140000.pcie: Nothing is connected in virtual bridges. Exiting..
> ...
>
> It is probably 50:50 on any boot whether it will probe pci successfully or
> fail to probe it.
>
> BTW, this is with the patch here applied:
> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142472.html

Yes this is the behaviour I was talking about in this series:

http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142520.html

These patches have been already added to staging-testing and should
work and found properly ports also for you.

>
> Regards
> Greg

Let me know any issue you might find.

Best regards,
     Sergio Paracuellos


>
>
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: mt7621-pci: don't return if get gpio fails
  2020-03-20 14:38   ` Sergio Paracuellos
@ 2020-03-20 15:08     ` Greg Ungerer
  2020-03-20 15:25       ` Sergio Paracuellos
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Ungerer @ 2020-03-20 15:08 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: NeilBrown, Greg KH, driverdev-devel

Hi Sergio,

On 21/3/20 12:38 am, Sergio Paracuellos wrote:
> On Fri, Mar 20, 2020 at 3:30 PM Greg Ungerer <gerg@kernel.org> wrote:
>> On 20/3/20 2:14 am, Sergio Paracuellos wrote:
[snip]
>> rt2880-pinmux pinctrl: pcie is already enabled
>> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
>> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
>> mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
>> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
>> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
>> mt7621-pci 1e140000.pcie: Nothing is connected in virtual bridges. Exiting..
>> ...
>>
>> It is probably 50:50 on any boot whether it will probe pci successfully or
>> fail to probe it.
>>
>> BTW, this is with the patch here applied:
>> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142472.html
> 
> Yes this is the behaviour I was talking about in this series:
> 
> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142520.html
> 
> These patches have been already added to staging-testing and should
> work and found properly ports also for you.
> 
> Let me know any issue you might find.

Ok, I am testing now a fresh up-to-date staging-testing.
I can see your most recent patches for the pci-phy at the top of the git log.
No other patches applied (just my devicetree for my hardware).

It dumps on every boot with:

...
rt2880-pinmux pinctrl: pcie is already enabled
mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
mt7621-pci-phy 1e149000.pcie-phy: PHY for 0xbe149000 (dual port = 1)
mt7621-pci-phy 1e14a000.pcie-phy: PHY for 0xbe14a000 (dual port = 0)
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
Unhandled kernel unaligned access[#1]:
CPU: 3 PID: 111 Comm: kworker/3:2 Not tainted 5.6.0-rc3-00347-g825c6f470c62-dirty #9
Workqueue: events deferred_probe_work_func
$ 0   : 00000000 00000001 5f60d043 8fe1ba80
$ 4   : 0000010d 01eb9000 00000000 00000000
$ 8   : 294b4c00 80940000 00000008 000000ce
$12   : 2e303030 00000000 00000000 65696370
$16   : ffffffed 0000010d 8e373cd0 8214c1e0
$20   : 00000000 82144c80 82144680 8214c250
$24   : 00000018 803ef8f4
$28   : 8e372000 8e373c60 8214c080 803940e8
Hi    : 00000125
Lo    : 122f2000
epc   : 807b3328 mutex_lock+0x8/0x44
ra    : 803940e8 phy_power_off+0x28/0xb0
Status: 1100fc03        KERNEL EXL IE
Cause : 00800010 (ExcCode 04)
BadVA : 0000010d
PrId  : 0001992f (MIPS 1004Kc)
Modules linked in:
Process kworker/3:2 (pid: 111, threadinfo=(ptrval), task=(ptrval), tls=00000000)
Stack : 8e373cd0 803fe4f4 8e372000 8e373c90 8214c080 804fde1c 8e373c98 808d62f4
         8e373c78 00000000 8214c254 804fe648 1e160000 804f27b8 00000001 808d62f4
         00000000 00000001 8214c228 808d62f4 80930000 809a0000 8fd47e10 808d63d4
         808d62d4 8fd47e10 808d0000 808d0000 8e373cd0 8e373cd0 809e2a74 809db510
         809db510 00000006 00000001 00000000 00000000 00000000 01000000 1e1440ff
         ...
Call Trace:
[<807b3328>] mutex_lock+0x8/0x44
[<803940e8>] phy_power_off+0x28/0xb0
[<804fe648>] mt7621_pci_probe+0xc20/0xd18
[<80402ab8>] platform_drv_probe+0x40/0x94
[<80400a74>] really_probe+0x104/0x364
[<803feb74>] bus_for_each_drv+0x84/0xdc
[<80400924>] __device_attach+0xdc/0x120
[<803ffb5c>] bus_probe_device+0xa0/0xbc
[<80400124>] deferred_probe_work_func+0x7c/0xbc
[<800420e8>] process_one_work+0x230/0x450
[<80042638>] worker_thread+0x330/0x5fc
[<80048eb0>] kthread+0x12c/0x134
[<80007438>] ret_from_kernel_thread+0x14/0x1c
Code: 24050002  27bdfff8  8f830000 <c0850000> 14a00005  00000000  00600825  e0810000  1020fffa

---[ end trace 8e3fadee03559cba ]---

Regards
Greg

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: mt7621-pci: don't return if get gpio fails
  2020-03-20 15:08     ` Greg Ungerer
@ 2020-03-20 15:25       ` Sergio Paracuellos
  2020-03-21  6:28         ` Greg Ungerer
  0 siblings, 1 reply; 7+ messages in thread
From: Sergio Paracuellos @ 2020-03-20 15:25 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: NeilBrown, Greg KH, driverdev-devel

Hi Greg,

On Fri, Mar 20, 2020 at 4:08 PM Greg Ungerer <gerg@kernel.org> wrote:
>
> Hi Sergio,
>
> On 21/3/20 12:38 am, Sergio Paracuellos wrote:
> > On Fri, Mar 20, 2020 at 3:30 PM Greg Ungerer <gerg@kernel.org> wrote:
> >> On 20/3/20 2:14 am, Sergio Paracuellos wrote:
> [snip]
> >> rt2880-pinmux pinctrl: pcie is already enabled
> >> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> >> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> >> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> >> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> >> mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
> >> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> >> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
> >> mt7621-pci 1e140000.pcie: Nothing is connected in virtual bridges. Exiting..
> >> ...
> >>
> >> It is probably 50:50 on any boot whether it will probe pci successfully or
> >> fail to probe it.
> >>
> >> BTW, this is with the patch here applied:
> >> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142472.html
> >
> > Yes this is the behaviour I was talking about in this series:
> >
> > http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142520.html
> >
> > These patches have been already added to staging-testing and should
> > work and found properly ports also for you.
> >
> > Let me know any issue you might find.
>
> Ok, I am testing now a fresh up-to-date staging-testing.
> I can see your most recent patches for the pci-phy at the top of the git log.
> No other patches applied (just my devicetree for my hardware).
>
> It dumps on every boot with:
>
> ...
> rt2880-pinmux pinctrl: pcie is already enabled
> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> mt7621-pci-phy 1e149000.pcie-phy: PHY for 0xbe149000 (dual port = 1)
> mt7621-pci-phy 1e14a000.pcie-phy: PHY for 0xbe14a000 (dual port = 0)
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> Unhandled kernel unaligned access[#1]:
> CPU: 3 PID: 111 Comm: kworker/3:2 Not tainted 5.6.0-rc3-00347-g825c6f470c62-dirty #9
> Workqueue: events deferred_probe_work_func
> $ 0   : 00000000 00000001 5f60d043 8fe1ba80
> $ 4   : 0000010d 01eb9000 00000000 00000000
> $ 8   : 294b4c00 80940000 00000008 000000ce
> $12   : 2e303030 00000000 00000000 65696370
> $16   : ffffffed 0000010d 8e373cd0 8214c1e0
> $20   : 00000000 82144c80 82144680 8214c250
> $24   : 00000018 803ef8f4
> $28   : 8e372000 8e373c60 8214c080 803940e8
> Hi    : 00000125
> Lo    : 122f2000
> epc   : 807b3328 mutex_lock+0x8/0x44
> ra    : 803940e8 phy_power_off+0x28/0xb0
> Status: 1100fc03        KERNEL EXL IE
> Cause : 00800010 (ExcCode 04)
> BadVA : 0000010d
> PrId  : 0001992f (MIPS 1004Kc)
> Modules linked in:
> Process kworker/3:2 (pid: 111, threadinfo=(ptrval), task=(ptrval), tls=00000000)
> Stack : 8e373cd0 803fe4f4 8e372000 8e373c90 8214c080 804fde1c 8e373c98 808d62f4
>          8e373c78 00000000 8214c254 804fe648 1e160000 804f27b8 00000001 808d62f4
>          00000000 00000001 8214c228 808d62f4 80930000 809a0000 8fd47e10 808d63d4
>          808d62d4 8fd47e10 808d0000 808d0000 8e373cd0 8e373cd0 809e2a74 809db510
>          809db510 00000006 00000001 00000000 00000000 00000000 01000000 1e1440ff
>          ...
> Call Trace:
> [<807b3328>] mutex_lock+0x8/0x44
> [<803940e8>] phy_power_off+0x28/0xb0
> [<804fe648>] mt7621_pci_probe+0xc20/0xd18
> [<80402ab8>] platform_drv_probe+0x40/0x94
> [<80400a74>] really_probe+0x104/0x364
> [<803feb74>] bus_for_each_drv+0x84/0xdc
> [<80400924>] __device_attach+0xdc/0x120
> [<803ffb5c>] bus_probe_device+0xa0/0xbc
> [<80400124>] deferred_probe_work_func+0x7c/0xbc
> [<800420e8>] process_one_work+0x230/0x450
> [<80042638>] worker_thread+0x330/0x5fc
> [<80048eb0>] kthread+0x12c/0x134
> [<80007438>] ret_from_kernel_thread+0x14/0x1c
> Code: 24050002  27bdfff8  8f830000 <c0850000> 14a00005  00000000  00600825  e0810000  1020fffa
>

Ok, this seems to be the access for slot 1 which I default set to true
as enabled ports because of the phy is for dual_port,
so because you are using only one of the two ports the
phy_power_off(port->phy); for slot 1 should not be triggered because
it is done for slot 0 if neccessary.

Can you try this small fix:

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 739504f7e4fc..23b51789f72e 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -517,7 +517,8 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie)
                if (!mt7621_pcie_port_is_linkup(port)) {
                        dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n",
                                slot);
-                       phy_power_off(port->phy);
+                       if (slot != 1)
+                               phy_power_off(port->phy);
                        mt7621_control_assert(port);
                        mt7621_pcie_port_clk_disable(port);
                        port->enabled = false;


> ---[ end trace 8e3fadee03559cba ]---
>
> Regards
> Greg

Regards,
    Sergio Paracuellos
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: mt7621-pci: don't return if get gpio fails
  2020-03-20 15:25       ` Sergio Paracuellos
@ 2020-03-21  6:28         ` Greg Ungerer
  2020-03-21  6:47           ` Sergio Paracuellos
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Ungerer @ 2020-03-21  6:28 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: NeilBrown, Greg KH, driverdev-devel

Hi Sergio,

On 21/3/20 1:25 am, Sergio Paracuellos wrote:
> On Fri, Mar 20, 2020 at 4:08 PM Greg Ungerer <gerg@kernel.org> wrote:
>> On 21/3/20 12:38 am, Sergio Paracuellos wrote:
>>> On Fri, Mar 20, 2020 at 3:30 PM Greg Ungerer <gerg@kernel.org> wrote:
>>>> On 20/3/20 2:14 am, Sergio Paracuellos wrote:
>> [snip]
>>>> rt2880-pinmux pinctrl: pcie is already enabled
>>>> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
>>>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
>>>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
>>>> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
>>>> mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
>>>> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
>>>> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
>>>> mt7621-pci 1e140000.pcie: Nothing is connected in virtual bridges. Exiting..
>>>> ...
>>>>
>>>> It is probably 50:50 on any boot whether it will probe pci successfully or
>>>> fail to probe it.
>>>>
>>>> BTW, this is with the patch here applied:
>>>> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142472.html
>>>
>>> Yes this is the behaviour I was talking about in this series:
>>>
>>> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142520.html
>>>
>>> These patches have been already added to staging-testing and should
>>> work and found properly ports also for you.
>>>
>>> Let me know any issue you might find.
>>
>> Ok, I am testing now a fresh up-to-date staging-testing.
>> I can see your most recent patches for the pci-phy at the top of the git log.
>> No other patches applied (just my devicetree for my hardware).
>>
>> It dumps on every boot with:
>>
>> ...
>> rt2880-pinmux pinctrl: pcie is already enabled
>> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
>> mt7621-pci-phy 1e149000.pcie-phy: PHY for 0xbe149000 (dual port = 1)
>> mt7621-pci-phy 1e14a000.pcie-phy: PHY for 0xbe14a000 (dual port = 0)
>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
>> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
>> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
>> Unhandled kernel unaligned access[#1]:
>> CPU: 3 PID: 111 Comm: kworker/3:2 Not tainted 5.6.0-rc3-00347-g825c6f470c62-dirty #9
>> Workqueue: events deferred_probe_work_func
>> $ 0   : 00000000 00000001 5f60d043 8fe1ba80
>> $ 4   : 0000010d 01eb9000 00000000 00000000
>> $ 8   : 294b4c00 80940000 00000008 000000ce
>> $12   : 2e303030 00000000 00000000 65696370
>> $16   : ffffffed 0000010d 8e373cd0 8214c1e0
>> $20   : 00000000 82144c80 82144680 8214c250
>> $24   : 00000018 803ef8f4
>> $28   : 8e372000 8e373c60 8214c080 803940e8
>> Hi    : 00000125
>> Lo    : 122f2000
>> epc   : 807b3328 mutex_lock+0x8/0x44
>> ra    : 803940e8 phy_power_off+0x28/0xb0
>> Status: 1100fc03        KERNEL EXL IE
>> Cause : 00800010 (ExcCode 04)
>> BadVA : 0000010d
>> PrId  : 0001992f (MIPS 1004Kc)
>> Modules linked in:
>> Process kworker/3:2 (pid: 111, threadinfo=(ptrval), task=(ptrval), tls=00000000)
>> Stack : 8e373cd0 803fe4f4 8e372000 8e373c90 8214c080 804fde1c 8e373c98 808d62f4
>>           8e373c78 00000000 8214c254 804fe648 1e160000 804f27b8 00000001 808d62f4
>>           00000000 00000001 8214c228 808d62f4 80930000 809a0000 8fd47e10 808d63d4
>>           808d62d4 8fd47e10 808d0000 808d0000 8e373cd0 8e373cd0 809e2a74 809db510
>>           809db510 00000006 00000001 00000000 00000000 00000000 01000000 1e1440ff
>>           ...
>> Call Trace:
>> [<807b3328>] mutex_lock+0x8/0x44
>> [<803940e8>] phy_power_off+0x28/0xb0
>> [<804fe648>] mt7621_pci_probe+0xc20/0xd18
>> [<80402ab8>] platform_drv_probe+0x40/0x94
>> [<80400a74>] really_probe+0x104/0x364
>> [<803feb74>] bus_for_each_drv+0x84/0xdc
>> [<80400924>] __device_attach+0xdc/0x120
>> [<803ffb5c>] bus_probe_device+0xa0/0xbc
>> [<80400124>] deferred_probe_work_func+0x7c/0xbc
>> [<800420e8>] process_one_work+0x230/0x450
>> [<80042638>] worker_thread+0x330/0x5fc
>> [<80048eb0>] kthread+0x12c/0x134
>> [<80007438>] ret_from_kernel_thread+0x14/0x1c
>> Code: 24050002  27bdfff8  8f830000 <c0850000> 14a00005  00000000  00600825  e0810000  1020fffa
>>
> 
> Ok, this seems to be the access for slot 1 which I default set to true
> as enabled ports because of the phy is for dual_port,
> so because you are using only one of the two ports the
> phy_power_off(port->phy); for slot 1 should not be triggered because
> it is done for slot 0 if neccessary.
> 
> Can you try this small fix:
> 
> diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c
> b/drivers/staging/mt7621-pci/pci-mt7621.c
> index 739504f7e4fc..23b51789f72e 100644
> --- a/drivers/staging/mt7621-pci/pci-mt7621.c
> +++ b/drivers/staging/mt7621-pci/pci-mt7621.c
> @@ -517,7 +517,8 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie)
>                  if (!mt7621_pcie_port_is_linkup(port)) {
>                          dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n",
>                                  slot);
> -                       phy_power_off(port->phy);
> +                       if (slot != 1)
> +                               phy_power_off(port->phy);
>                          mt7621_control_assert(port);
>                          mt7621_pcie_port_clk_disable(port);
>                          port->enabled = false;
> 
> 
>> ---[ end trace 8e3fadee03559cba ]---

Yep, that fixes it. No more dumps.

In limited testing so far every boot up has probed the PCI bu successfully.
I'll keep testing, and report any problems.

Note that I am running with the modified mt7621.dtsi that has the reset
lines for PCIe limited to only GPIO19. (GPIO7 and GPIO8 removed from reset).

Regards
Greg

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: mt7621-pci: don't return if get gpio fails
  2020-03-21  6:28         ` Greg Ungerer
@ 2020-03-21  6:47           ` Sergio Paracuellos
  0 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2020-03-21  6:47 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: NeilBrown, Greg KH, driverdev-devel

Hi Greg,

On Sat, Mar 21, 2020 at 7:28 AM Greg Ungerer <gerg@kernel.org> wrote:
>
> Hi Sergio,
>
> On 21/3/20 1:25 am, Sergio Paracuellos wrote:
> > On Fri, Mar 20, 2020 at 4:08 PM Greg Ungerer <gerg@kernel.org> wrote:
> >> On 21/3/20 12:38 am, Sergio Paracuellos wrote:
> >>> On Fri, Mar 20, 2020 at 3:30 PM Greg Ungerer <gerg@kernel.org> wrote:
> >>>> On 20/3/20 2:14 am, Sergio Paracuellos wrote:
> >> [snip]
> >>>> rt2880-pinmux pinctrl: pcie is already enabled
> >>>> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> >>>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> >>>> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> >>>> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> >>>> mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
> >>>> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> >>>> mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK)
> >>>> mt7621-pci 1e140000.pcie: Nothing is connected in virtual bridges. Exiting..
> >>>> ...
> >>>>
> >>>> It is probably 50:50 on any boot whether it will probe pci successfully or
> >>>> fail to probe it.
> >>>>
> >>>> BTW, this is with the patch here applied:
> >>>> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142472.html
> >>>
> >>> Yes this is the behaviour I was talking about in this series:
> >>>
> >>> http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2020-March/142520.html
> >>>
> >>> These patches have been already added to staging-testing and should
> >>> work and found properly ports also for you.
> >>>
> >>> Let me know any issue you might find.
> >>
> >> Ok, I am testing now a fresh up-to-date staging-testing.
> >> I can see your most recent patches for the pci-phy at the top of the git log.
> >> No other patches applied (just my devicetree for my hardware).
> >>
> >> It dumps on every boot with:
> >>
> >> ...
> >> rt2880-pinmux pinctrl: pcie is already enabled
> >> mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
> >> mt7621-pci-phy 1e149000.pcie-phy: PHY for 0xbe149000 (dual port = 1)
> >> mt7621-pci-phy 1e14a000.pcie-phy: PHY for 0xbe14a000 (dual port = 0)
> >> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> >> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> >> mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK)
> >> Unhandled kernel unaligned access[#1]:
> >> CPU: 3 PID: 111 Comm: kworker/3:2 Not tainted 5.6.0-rc3-00347-g825c6f470c62-dirty #9
> >> Workqueue: events deferred_probe_work_func
> >> $ 0   : 00000000 00000001 5f60d043 8fe1ba80
> >> $ 4   : 0000010d 01eb9000 00000000 00000000
> >> $ 8   : 294b4c00 80940000 00000008 000000ce
> >> $12   : 2e303030 00000000 00000000 65696370
> >> $16   : ffffffed 0000010d 8e373cd0 8214c1e0
> >> $20   : 00000000 82144c80 82144680 8214c250
> >> $24   : 00000018 803ef8f4
> >> $28   : 8e372000 8e373c60 8214c080 803940e8
> >> Hi    : 00000125
> >> Lo    : 122f2000
> >> epc   : 807b3328 mutex_lock+0x8/0x44
> >> ra    : 803940e8 phy_power_off+0x28/0xb0
> >> Status: 1100fc03        KERNEL EXL IE
> >> Cause : 00800010 (ExcCode 04)
> >> BadVA : 0000010d
> >> PrId  : 0001992f (MIPS 1004Kc)
> >> Modules linked in:
> >> Process kworker/3:2 (pid: 111, threadinfo=(ptrval), task=(ptrval), tls=00000000)
> >> Stack : 8e373cd0 803fe4f4 8e372000 8e373c90 8214c080 804fde1c 8e373c98 808d62f4
> >>           8e373c78 00000000 8214c254 804fe648 1e160000 804f27b8 00000001 808d62f4
> >>           00000000 00000001 8214c228 808d62f4 80930000 809a0000 8fd47e10 808d63d4
> >>           808d62d4 8fd47e10 808d0000 808d0000 8e373cd0 8e373cd0 809e2a74 809db510
> >>           809db510 00000006 00000001 00000000 00000000 00000000 01000000 1e1440ff
> >>           ...
> >> Call Trace:
> >> [<807b3328>] mutex_lock+0x8/0x44
> >> [<803940e8>] phy_power_off+0x28/0xb0
> >> [<804fe648>] mt7621_pci_probe+0xc20/0xd18
> >> [<80402ab8>] platform_drv_probe+0x40/0x94
> >> [<80400a74>] really_probe+0x104/0x364
> >> [<803feb74>] bus_for_each_drv+0x84/0xdc
> >> [<80400924>] __device_attach+0xdc/0x120
> >> [<803ffb5c>] bus_probe_device+0xa0/0xbc
> >> [<80400124>] deferred_probe_work_func+0x7c/0xbc
> >> [<800420e8>] process_one_work+0x230/0x450
> >> [<80042638>] worker_thread+0x330/0x5fc
> >> [<80048eb0>] kthread+0x12c/0x134
> >> [<80007438>] ret_from_kernel_thread+0x14/0x1c
> >> Code: 24050002  27bdfff8  8f830000 <c0850000> 14a00005  00000000  00600825  e0810000  1020fffa
> >>
> >
> > Ok, this seems to be the access for slot 1 which I default set to true
> > as enabled ports because of the phy is for dual_port,
> > so because you are using only one of the two ports the
> > phy_power_off(port->phy); for slot 1 should not be triggered because
> > it is done for slot 0 if neccessary.
> >
> > Can you try this small fix:
> >
> > diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c
> > b/drivers/staging/mt7621-pci/pci-mt7621.c
> > index 739504f7e4fc..23b51789f72e 100644
> > --- a/drivers/staging/mt7621-pci/pci-mt7621.c
> > +++ b/drivers/staging/mt7621-pci/pci-mt7621.c
> > @@ -517,7 +517,8 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie)
> >                  if (!mt7621_pcie_port_is_linkup(port)) {
> >                          dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n",
> >                                  slot);
> > -                       phy_power_off(port->phy);
> > +                       if (slot != 1)
> > +                               phy_power_off(port->phy);
> >                          mt7621_control_assert(port);
> >                          mt7621_pcie_port_clk_disable(port);
> >                          port->enabled = false;
> >
> >
> >> ---[ end trace 8e3fadee03559cba ]---
>
> Yep, that fixes it. No more dumps.
>
> In limited testing so far every boot up has probed the PCI bu successfully.

Good news :)

> I'll keep testing, and report any problems.
>
> Note that I am running with the modified mt7621.dtsi that has the reset
> lines for PCIe limited to only GPIO19. (GPIO7 and GPIO8 removed from reset).

Please, let me know any issue you can find.

>
> Regards
> Greg

Best regards,
    Sergio Paracuellos
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 16:14 [PATCH] staging: mt7621-pci: don't return if get gpio fails Sergio Paracuellos
2020-03-20 14:30 ` Greg Ungerer
2020-03-20 14:38   ` Sergio Paracuellos
2020-03-20 15:08     ` Greg Ungerer
2020-03-20 15:25       ` Sergio Paracuellos
2020-03-21  6:28         ` Greg Ungerer
2020-03-21  6:47           ` Sergio Paracuellos

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git