Commit 1c942c94 authored by David S. Miller's avatar David S. Miller

Merge branch 'hns-deferred-probe'

lipeng says:

====================
net: hns: bug fix for HNS driver

This patchset add support defered dsaf probe when mdio and
mbigen module is not insmod.

For more details, please refer to individual patch.

change log:
V4 - > V5:
1. Float on net-next;
2. Delete patch "net: hns: fixed bug that skb used after kfree"
   from this patchset;

V3 -> V4:
1. Delete redundant commit message;
2. Add Reviewed-by: Matthias Brugger <mbrugger@suse.com>;

V2 -> V3:
1. Check return value when  platform_get_irq in hns_rcb_get_cfg;

V1 -> V2:
1. Return appropriate errno in hns_mac_register_phy;
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ba1d82e6 804ffe5c
...@@ -696,6 +696,8 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb, ...@@ -696,6 +696,8 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,
rc = phy_device_register(phy); rc = phy_device_register(phy);
if (rc) { if (rc) {
phy_device_free(phy); phy_device_free(phy);
dev_err(&mdio->dev, "registered phy fail at address %i\n",
addr);
return -ENODEV; return -ENODEV;
} }
...@@ -706,7 +708,7 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb, ...@@ -706,7 +708,7 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,
return 0; return 0;
} }
static void hns_mac_register_phy(struct hns_mac_cb *mac_cb) static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
{ {
struct acpi_reference_args args; struct acpi_reference_args args;
struct platform_device *pdev; struct platform_device *pdev;
...@@ -716,24 +718,39 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb) ...@@ -716,24 +718,39 @@ static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
/* Loop over the child nodes and register a phy_device for each one */ /* Loop over the child nodes and register a phy_device for each one */
if (!to_acpi_device_node(mac_cb->fw_port)) if (!to_acpi_device_node(mac_cb->fw_port))
return; return -ENODEV;
rc = acpi_node_get_property_reference( rc = acpi_node_get_property_reference(
mac_cb->fw_port, "mdio-node", 0, &args); mac_cb->fw_port, "mdio-node", 0, &args);
if (rc) if (rc)
return; return rc;
addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port); addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
if (addr < 0) if (addr < 0)
return; return addr;
/* dev address in adev */ /* dev address in adev */
pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev)); pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev));
if (!pdev) {
dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
mac_cb->mac_id);
return -EINVAL;
}
mii_bus = platform_get_drvdata(pdev); mii_bus = platform_get_drvdata(pdev);
if (!mii_bus) {
dev_err(mac_cb->dev,
"mac%d mdio is NULL, dsaf will probe again later\n",
mac_cb->mac_id);
return -EPROBE_DEFER;
}
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr); rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
if (!rc) if (!rc)
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n", dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr); mac_cb->mac_id, addr);
return rc;
} }
#define MAC_MEDIA_TYPE_MAX_LEN 16 #define MAC_MEDIA_TYPE_MAX_LEN 16
...@@ -754,7 +771,7 @@ static const struct { ...@@ -754,7 +771,7 @@ static const struct {
*@np:device node *@np:device node
* return: 0 --success, negative --fail * return: 0 --success, negative --fail
*/ */
static int hns_mac_get_info(struct hns_mac_cb *mac_cb) static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
{ {
struct device_node *np; struct device_node *np;
struct regmap *syscon; struct regmap *syscon;
...@@ -864,7 +881,15 @@ static int hns_mac_get_info(struct hns_mac_cb *mac_cb) ...@@ -864,7 +881,15 @@ static int hns_mac_get_info(struct hns_mac_cb *mac_cb)
} }
} }
} else if (is_acpi_node(mac_cb->fw_port)) { } else if (is_acpi_node(mac_cb->fw_port)) {
hns_mac_register_phy(mac_cb); ret = hns_mac_register_phy(mac_cb);
/*
* Mac can work well if there is phy or not.If the port don't
* connect with phy, the return value will be ignored. Only
* when there is phy but can't find mdio bus, the return value
* will be handled.
*/
if (ret == -EPROBE_DEFER)
return ret;
} else { } else {
dev_err(mac_cb->dev, "mac%d cannot find phy node\n", dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
mac_cb->mac_id); mac_cb->mac_id);
...@@ -1026,6 +1051,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev) ...@@ -1026,6 +1051,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
dsaf_dev->mac_cb[port_id] = mac_cb; dsaf_dev->mac_cb[port_id] = mac_cb;
} }
} }
/* init mac_cb for all port */ /* init mac_cb for all port */
for (port_id = 0; port_id < max_port_num; port_id++) { for (port_id = 0; port_id < max_port_num; port_id++) {
mac_cb = dsaf_dev->mac_cb[port_id]; mac_cb = dsaf_dev->mac_cb[port_id];
...@@ -1035,6 +1061,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev) ...@@ -1035,6 +1061,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
ret = hns_mac_get_cfg(dsaf_dev, mac_cb); ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
if (ret) if (ret)
return ret; return ret;
ret = hns_mac_init_ex(mac_cb); ret = hns_mac_init_ex(mac_cb);
if (ret) if (ret)
return ret; return ret;
......
...@@ -510,7 +510,9 @@ int hns_ppe_init(struct dsaf_device *dsaf_dev) ...@@ -510,7 +510,9 @@ int hns_ppe_init(struct dsaf_device *dsaf_dev)
hns_ppe_get_cfg(dsaf_dev->ppe_common[i]); hns_ppe_get_cfg(dsaf_dev->ppe_common[i]);
hns_rcb_get_cfg(dsaf_dev->rcb_common[i]); ret = hns_rcb_get_cfg(dsaf_dev->rcb_common[i]);
if (ret)
goto get_cfg_fail;
} }
for (i = 0; i < HNS_PPE_COM_NUM; i++) for (i = 0; i < HNS_PPE_COM_NUM; i++)
......
...@@ -492,7 +492,7 @@ static int hns_rcb_get_base_irq_idx(struct rcb_common_cb *rcb_common) ...@@ -492,7 +492,7 @@ static int hns_rcb_get_base_irq_idx(struct rcb_common_cb *rcb_common)
*hns_rcb_get_cfg - get rcb config *hns_rcb_get_cfg - get rcb config
*@rcb_common: rcb common device *@rcb_common: rcb common device
*/ */
void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common) int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
{ {
struct ring_pair_cb *ring_pair_cb; struct ring_pair_cb *ring_pair_cb;
u32 i; u32 i;
...@@ -517,10 +517,16 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common) ...@@ -517,10 +517,16 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] = ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] =
is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2 + 1) : is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2 + 1) :
platform_get_irq(pdev, base_irq_idx + i * 3); platform_get_irq(pdev, base_irq_idx + i * 3);
if ((ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] == -EPROBE_DEFER) ||
(ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] == -EPROBE_DEFER))
return -EPROBE_DEFER;
ring_pair_cb->q.phy_base = ring_pair_cb->q.phy_base =
RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i); RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i);
hns_rcb_ring_pair_get_cfg(ring_pair_cb); hns_rcb_ring_pair_get_cfg(ring_pair_cb);
} }
return 0;
} }
/** /**
......
...@@ -121,7 +121,7 @@ int hns_rcb_common_get_cfg(struct dsaf_device *dsaf_dev, int comm_index); ...@@ -121,7 +121,7 @@ int hns_rcb_common_get_cfg(struct dsaf_device *dsaf_dev, int comm_index);
void hns_rcb_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index); void hns_rcb_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index);
int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common); int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common);
void hns_rcb_start(struct hnae_queue *q, u32 val); void hns_rcb_start(struct hnae_queue *q, u32 val);
void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common); int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
void hns_rcb_get_queue_mode(enum dsaf_mode dsaf_mode, void hns_rcb_get_queue_mode(enum dsaf_mode dsaf_mode,
u16 *max_vfn, u16 *max_q_per_vf); u16 *max_vfn, u16 *max_q_per_vf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment