Skip to content

Commit

Permalink
phy: rockchip: inno-usb2: add devm action for otg wake lock
Browse files Browse the repository at this point in the history
The otg wakelock should be destroyed when the device probe failed
or removed, else may cause the following kernel errors.

  list_add corruption. next->prev should be prev (ffffffc01209d3c8), but
  was 0000000000000000. (next=ffffff800350faf8).
  ------------[ cut here ]------------
  kernel BUG at lib/list_debug.c:25!
  Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
  Modules linked in:
  CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.10.110 rockchip-linux#83
  Hardware name: Rockchip RK3562 EVB1 LP4X V10 Board (DT)
  pstate: 60400085 (nZCv daIf +PAN -UAO -TCO BTYPE=--)
  pc : __list_add_valid+0x6c/0x88
  lr : __list_add_valid+0x6c/0x88
  [...]
  Call trace:
   __list_add_valid+0x7c/0x98
   wakeup_source_register+0x120/0x160
   wakeup_source_register+0x120/0x160
   device_init_wakeup+0x60/0xf4
   [...]

So add devm action to fix it.

Signed-off-by: Frank Wang <[email protected]>
Change-Id: If54a299a694414ad759002e4f6c4187448ccdb15
  • Loading branch information
Frank Wang committed Jan 12, 2023
1 parent a4b5fcb commit a057f50
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions drivers/phy/rockchip/phy-rockchip-inno-usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,11 @@ static int rockchip_otg_event(struct notifier_block *nb,
return NOTIFY_DONE;
}

static void rockchip_otg_wake_lock_destroy(void *data)
{
wake_lock_destroy((struct wake_lock *)(data));
}

static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
struct rockchip_usb2phy_port *rport,
struct device_node *child_np)
Expand Down Expand Up @@ -1885,6 +1890,11 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
property_enable(base, &rport->port_cfg->bvalid_set, false);

wake_lock_init(&rport->wakelock, WAKE_LOCK_SUSPEND, "rockchip_otg");
ret = devm_add_action_or_reset(rphy->dev, rockchip_otg_wake_lock_destroy,
&rport->wakelock);
if (ret)
return ret;

INIT_DELAYED_WORK(&rport->bypass_uart_work,
rockchip_usb_bypass_uart_work);
INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
Expand All @@ -1897,7 +1907,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
EXTCON_USB_HOST, &rport->event_nb);
if (ret) {
dev_err(rphy->dev, "register USB HOST notifier failed\n");
goto err;
return ret;
}
}

Expand All @@ -1913,10 +1923,6 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
rport->suspended = true;

return 0;

err:
wake_lock_destroy(&rport->wakelock);
return ret;
}

static int rockchip_usb2phy_probe(struct platform_device *pdev)
Expand Down

0 comments on commit a057f50

Please sign in to comment.