Netdev List
 help / color / mirror / Atom feed
From: "lipeng (Y)" <lipeng321@huawei.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
	Yankejian <yankejian@huawei.com>, <davem@davemloft.net>,
	<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
	<allenhuangsz10@gmail.com>, <huangdaode@hisilicon.com>,
	<hjat.hejun@huawei.com>, <zhangping5@huawei.com>,
	<qichengming@huawei.com>, <qumingguang@hisilicon.com>,
	<zhouhuiru@huawei.com>
Cc: <netdev@vger.kernel.org>, <charles.chenxin@huawei.com>,
	<linuxarm@huawei.com>
Subject: Re: [PATCH net-next 2/3] net: hns: support deferred probe when no mdio
Date: Fri, 21 Apr 2017 15:18:37 +0800	[thread overview]
Message-ID: <22ba80ac-b83e-9017-0bd5-fe4e03edfd49@huawei.com> (raw)
In-Reply-To: <5c299e38-88f0-9801-5e7b-477e6fa0db18@gmail.com>



On 2017/4/20 19:13, Matthias Brugger wrote:
> On 18/04/17 12:12, Yankejian wrote:
>> From: lipeng <lipeng321@huawei.com>
>>
>> In the hip06 and hip07 SoCs, phy connect to mdio bus.The mdio
>> module is probed with module_init, and, as such,
>> is not guaranteed to probe before the HNS driver. So we need
>> to support deferred probe.
>>
>> We check for probe deferral in the mac init, so we not init DSAF
>> when there is no mdio, and free all resource, to later learn that
>> we need to defer the probe.
>>
>> Signed-off-by: lipeng <lipeng321@huawei.com>
>
> on which kernel version is this patch based?
> I checked against next-20170420 and it does not apply.
>

Will refloat this patchset on net.

thanks.
lipeng
>
>> ---
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 34 
>> +++++++++++++++++++----
>>  1 file changed, 28 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
>> b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> index bdd8cdd..284ebfe 100644
>> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> @@ -735,6 +735,8 @@ static int hns_mac_init_ex(struct hns_mac_cb 
>> *mac_cb)
>>      rc = phy_device_register(phy);
>>      if (rc) {
>>          phy_device_free(phy);
>> +        dev_err(&mdio->dev, "registered phy fail at address %i\n",
>> +            addr);
>>          return -ENODEV;
>>      }
>>
>> @@ -745,7 +747,7 @@ static int hns_mac_init_ex(struct hns_mac_cb 
>> *mac_cb)
>>      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 platform_device *pdev;
>> @@ -755,24 +757,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 */
>>      if (!to_acpi_device_node(mac_cb->fw_port))
>> -        return;
>> +        return 0;
>
> Please return appropriate errno.
>
>>
>>      rc = acpi_node_get_property_reference(
>>              mac_cb->fw_port, "mdio-node", 0, &args);
>>      if (rc)
>> -        return;
>> +        return 0;
>
> Please return appropriate errno.
>
>>
>>      addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
>>      if (addr < 0)
>> -        return;
>> +        return 0;
>
> Shouldn't we just error out here by returning addr?
>
>>
>>      /* dev address in 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 0;
>
> Please return appropriate errno.
>
> Regards,
> Matthias
>
>> +    }
>> +
>>      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);
>>      if (!rc)
>>          dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
>>              mac_cb->mac_id, addr);
>> +
>> +    return rc;
>>  }
>>
>>  #define MAC_MEDIA_TYPE_MAX_LEN        16
>> @@ -793,7 +810,7 @@ static void hns_mac_register_phy(struct 
>> hns_mac_cb *mac_cb)
>>   *@np:device node
>>   * 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 regmap *syscon;
>> @@ -903,7 +920,10 @@ static int  hns_mac_get_info(struct hns_mac_cb 
>> *mac_cb)
>>              }
>>          }
>>      } else if (is_acpi_node(mac_cb->fw_port)) {
>> -        hns_mac_register_phy(mac_cb);
>> +        ret = hns_mac_register_phy(mac_cb);
>> +
>> +        if (ret)
>> +            return ret;
>>      } else {
>>          dev_err(mac_cb->dev, "mac%d cannot find phy node\n",
>>              mac_cb->mac_id);
>> @@ -1065,6 +1085,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
>>              dsaf_dev->mac_cb[port_id] = mac_cb;
>>          }
>>      }
>> +
>>      /* init mac_cb for all port */
>>      for (port_id = 0; port_id < max_port_num; port_id++) {
>>          mac_cb = dsaf_dev->mac_cb[port_id];
>> @@ -1074,6 +1095,7 @@ int hns_mac_init(struct dsaf_device *dsaf_dev)
>>          ret = hns_mac_get_cfg(dsaf_dev, mac_cb);
>>          if (ret)
>>              return ret;
>> +
>>          ret = hns_mac_init_ex(mac_cb);
>>          if (ret)
>>              return ret;
>>
>
> .
>

  reply	other threads:[~2017-04-21  7:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 10:12 [PATCH net-next 0/3] net: hns: add deferred probe and fix a bug Yankejian
2017-04-18 10:12 ` [PATCH net-next 1/3] net: hns: support deferred probe when can not obtain irq Yankejian
2017-04-18 10:12 ` [PATCH net-next 2/3] net: hns: support deferred probe when no mdio Yankejian
2017-04-20 11:13   ` Matthias Brugger
2017-04-21  7:18     ` lipeng (Y) [this message]
2017-04-18 10:12 ` [PATCH net-next 3/3] net: hns: fixed bug that skb used after kfree Yankejian

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=22ba80ac-b83e-9017-0bd5-fe4e03edfd49@huawei.com \
    --to=lipeng321@huawei.com \
    --cc=allenhuangsz10@gmail.com \
    --cc=charles.chenxin@huawei.com \
    --cc=davem@davemloft.net \
    --cc=hjat.hejun@huawei.com \
    --cc=huangdaode@hisilicon.com \
    --cc=linuxarm@huawei.com \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=qichengming@huawei.com \
    --cc=qumingguang@hisilicon.com \
    --cc=salil.mehta@huawei.com \
    --cc=yankejian@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    --cc=zhangping5@huawei.com \
    --cc=zhouhuiru@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox