ramips: fix MikroTik 750Gr3 ports MAC addresses
[openwrt/staging/wigyori.git] / target / linux / ramips / patches-5.4 / 0120-staging-mt7621-pci-properly-power-off-dual-ported-pc.patch
1 From 5fcded5e857cf66c9592e4be28c4dab4520c9177 Mon Sep 17 00:00:00 2001
2 From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
3 Date: Thu, 9 Apr 2020 13:16:52 +0200
4 Subject: [PATCH] staging: mt7621-pci: properly power off dual-ported pcie phy
5
6 Pcie phy for pcie0 and pcie1 is shared using a dual ported
7 one. Current code was assuming that if nothing is connected
8 in pcie0 it won't be also nothing connected in pcie1. This
9 assumtion is wrong for some devices such us 'Mikrotik rbm33g'
10 and 'ZyXEL LTE3301-PLUS' where only connecting a card to the
11 second bus on the phy is possible. For such devices kernel
12 hangs in the same point because of the wrong poweroff of the
13 phy getting the following trace:
14
15 mt7621-pci-phy 1e149000.pcie-phy: PHY for 0xbe149000 (dual port = 1)
16 mt7621-pci-phy 1e14a000.pcie-phy: PHY for 0xbe14a000 (dual port = 0)
17 mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
18 mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
19 mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK)
20 [hangs]
21
22 The wrong assumption is located in the 'mt7621_pcie_init_ports'
23 function where we are just making a power off of the phy for
24 slots 0 and 2 if nothing is connected in them. Hence, only
25 poweroff the phy if nothing is connected in both slot 0 and
26 slot 1 avoiding the kernel to hang.
27
28 Fixes: 5737cfe87a9c ("staging: mt7621-pci: avoid to poweroff the phy for slot one")
29 Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
30 Link: https://lore.kernel.org/r/20200409111652.30964-1-sergio.paracuellos@gmail.com
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 ---
33 drivers/staging/mt7621-pci/pci-mt7621.c | 12 ++++++++++--
34 1 file changed, 10 insertions(+), 2 deletions(-)
35
36 --- a/drivers/staging/mt7621-pci/pci-mt7621.c
37 +++ b/drivers/staging/mt7621-pci/pci-mt7621.c
38 @@ -502,17 +502,25 @@ static void mt7621_pcie_init_ports(struc
39
40 mt7621_pcie_reset_ep_deassert(pcie);
41
42 + tmp = NULL;
43 list_for_each_entry(port, &pcie->ports, list) {
44 u32 slot = port->slot;
45
46 if (!mt7621_pcie_port_is_linkup(port)) {
47 dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n",
48 slot);
49 - if (slot != 1)
50 - phy_power_off(port->phy);
51 mt7621_control_assert(port);
52 mt7621_pcie_port_clk_disable(port);
53 port->enabled = false;
54 +
55 + if (slot == 0) {
56 + tmp = port;
57 + continue;
58 + }
59 +
60 + if (slot == 1 && tmp && !tmp->enabled)
61 + phy_power_off(tmp->phy);
62 +
63 }
64 }
65 }