aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2016-06-13 05:49:36 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-15 01:37:48 -0400
commita028a9e003f299cf427d98501861bbbb4f5ba7a5 (patch)
tree9c9470acc64f7160b5cc00fdf43a645367e9de63 /drivers/net/usb
parente8eb36cd8ca93f52f738c6087073202c44ac7746 (diff)
r8152: move the settings of PHY to a work queue
Move the settings of PHY to a work queue and schedule it after rtl_ops.init(). There are some reasons for this. First, the settings are only needed for the first time initialization or after the power down occurs. Second, the settings are independent with the others. Last, the settings may take more time than the others. Leave they in probe() or open() may delay the following flows. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/r8152.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 161c25e18865..46fe9a7dc996 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -602,7 +602,7 @@ struct r8152 {
602 struct list_head rx_done, tx_free; 602 struct list_head rx_done, tx_free;
603 struct sk_buff_head tx_queue, rx_queue; 603 struct sk_buff_head tx_queue, rx_queue;
604 spinlock_t rx_lock, tx_lock; 604 spinlock_t rx_lock, tx_lock;
605 struct delayed_work schedule; 605 struct delayed_work schedule, hw_phy_work;
606 struct mii_if_info mii; 606 struct mii_if_info mii;
607 struct mutex control; /* use for hw setting */ 607 struct mutex control; /* use for hw setting */
608#ifdef CONFIG_PM_SLEEP 608#ifdef CONFIG_PM_SLEEP
@@ -619,6 +619,7 @@ struct r8152 {
619 int (*eee_get)(struct r8152 *, struct ethtool_eee *); 619 int (*eee_get)(struct r8152 *, struct ethtool_eee *);
620 int (*eee_set)(struct r8152 *, struct ethtool_eee *); 620 int (*eee_set)(struct r8152 *, struct ethtool_eee *);
621 bool (*in_nway)(struct r8152 *); 621 bool (*in_nway)(struct r8152 *);
622 void (*hw_phy_cfg)(struct r8152 *);
622 } rtl_ops; 623 } rtl_ops;
623 624
624 int intr_interval; 625 int intr_interval;
@@ -2499,8 +2500,6 @@ static void r8152b_exit_oob(struct r8152 *tp)
2499 2500
2500 rxdy_gated_en(tp, true); 2501 rxdy_gated_en(tp, true);
2501 r8153_teredo_off(tp); 2502 r8153_teredo_off(tp);
2502 r8152b_hw_phy_cfg(tp);
2503
2504 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); 2503 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
2505 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, 0x00); 2504 ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, 0x00);
2506 2505
@@ -2678,8 +2677,6 @@ static void r8153_first_init(struct r8152 *tp)
2678 ocp_data &= ~RCR_ACPT_ALL; 2677 ocp_data &= ~RCR_ACPT_ALL;
2679 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); 2678 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
2680 2679
2681 r8153_hw_phy_cfg(tp);
2682
2683 rtl8152_nic_reset(tp); 2680 rtl8152_nic_reset(tp);
2684 2681
2685 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); 2682 ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
@@ -3040,6 +3037,25 @@ out1:
3040 usb_autopm_put_interface(tp->intf); 3037 usb_autopm_put_interface(tp->intf);
3041} 3038}
3042 3039
3040static void rtl_hw_phy_work_func_t(struct work_struct *work)
3041{
3042 struct r8152 *tp = container_of(work, struct r8152, hw_phy_work.work);
3043
3044 if (test_bit(RTL8152_UNPLUG, &tp->flags))
3045 return;
3046
3047 if (usb_autopm_get_interface(tp->intf) < 0)
3048 return;
3049
3050 mutex_lock(&tp->control);
3051
3052 tp->rtl_ops.hw_phy_cfg(tp);
3053
3054 mutex_unlock(&tp->control);
3055
3056 usb_autopm_put_interface(tp->intf);
3057}
3058
3043#ifdef CONFIG_PM_SLEEP 3059#ifdef CONFIG_PM_SLEEP
3044static int rtl_notifier(struct notifier_block *nb, unsigned long action, 3060static int rtl_notifier(struct notifier_block *nb, unsigned long action,
3045 void *data) 3061 void *data)
@@ -3518,6 +3534,7 @@ static int rtl8152_resume(struct usb_interface *intf)
3518 3534
3519 if (!test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 3535 if (!test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3520 tp->rtl_ops.init(tp); 3536 tp->rtl_ops.init(tp);
3537 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
3521 netif_device_attach(tp->netdev); 3538 netif_device_attach(tp->netdev);
3522 } 3539 }
3523 3540
@@ -4122,6 +4139,7 @@ static int rtl_ops_init(struct r8152 *tp)
4122 ops->eee_get = r8152_get_eee; 4139 ops->eee_get = r8152_get_eee;
4123 ops->eee_set = r8152_set_eee; 4140 ops->eee_set = r8152_set_eee;
4124 ops->in_nway = rtl8152_in_nway; 4141 ops->in_nway = rtl8152_in_nway;
4142 ops->hw_phy_cfg = r8152b_hw_phy_cfg;
4125 break; 4143 break;
4126 4144
4127 case RTL_VER_03: 4145 case RTL_VER_03:
@@ -4137,6 +4155,7 @@ static int rtl_ops_init(struct r8152 *tp)
4137 ops->eee_get = r8153_get_eee; 4155 ops->eee_get = r8153_get_eee;
4138 ops->eee_set = r8153_set_eee; 4156 ops->eee_set = r8153_set_eee;
4139 ops->in_nway = rtl8153_in_nway; 4157 ops->in_nway = rtl8153_in_nway;
4158 ops->hw_phy_cfg = r8153_hw_phy_cfg;
4140 break; 4159 break;
4141 4160
4142 default: 4161 default:
@@ -4183,6 +4202,7 @@ static int rtl8152_probe(struct usb_interface *intf,
4183 4202
4184 mutex_init(&tp->control); 4203 mutex_init(&tp->control);
4185 INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t); 4204 INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t);
4205 INIT_DELAYED_WORK(&tp->hw_phy_work, rtl_hw_phy_work_func_t);
4186 4206
4187 netdev->netdev_ops = &rtl8152_netdev_ops; 4207 netdev->netdev_ops = &rtl8152_netdev_ops;
4188 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; 4208 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT;
@@ -4225,6 +4245,7 @@ static int rtl8152_probe(struct usb_interface *intf,
4225 intf->needs_remote_wakeup = 1; 4245 intf->needs_remote_wakeup = 1;
4226 4246
4227 tp->rtl_ops.init(tp); 4247 tp->rtl_ops.init(tp);
4248 queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
4228 set_ethernet_addr(tp); 4249 set_ethernet_addr(tp);
4229 4250
4230 usb_set_intfdata(intf, tp); 4251 usb_set_intfdata(intf, tp);
@@ -4270,6 +4291,7 @@ static void rtl8152_disconnect(struct usb_interface *intf)
4270 4291
4271 netif_napi_del(&tp->napi); 4292 netif_napi_del(&tp->napi);
4272 unregister_netdev(tp->netdev); 4293 unregister_netdev(tp->netdev);
4294 cancel_delayed_work_sync(&tp->hw_phy_work);
4273 tp->rtl_ops.unload(tp); 4295 tp->rtl_ops.unload(tp);
4274 free_netdev(tp->netdev); 4296 free_netdev(tp->netdev);
4275 } 4297 }