Loading drivers/usb/pd/policy_engine.c +29 −3 Original line number Diff line number Diff line Loading @@ -463,6 +463,7 @@ struct usbpd { struct mutex svid_handler_lock; struct list_head svid_handlers; ktime_t svdm_start_time; bool vdm_in_suspend; struct list_head instance; Loading Loading @@ -658,15 +659,21 @@ static struct usbpd_svid_handler *find_svid_handler(struct usbpd *pd, u16 svid) { struct usbpd_svid_handler *handler; /* in_interrupt() == true when handling VDM RX during suspend */ if (!in_interrupt()) mutex_lock(&pd->svid_handler_lock); list_for_each_entry(handler, &pd->svid_handlers, entry) { if (svid == handler->svid) { if (!in_interrupt()) mutex_unlock(&pd->svid_handler_lock); return handler; } } if (!in_interrupt()) mutex_unlock(&pd->svid_handler_lock); return NULL; } Loading Loading @@ -1073,6 +1080,8 @@ static struct rx_msg *pd_ext_msg_received(struct usbpd *pd, u16 header, u8 *buf, return rx_msg; /* queue it for usbpd_sm */ } static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg); static void phy_msg_received(struct usbpd *pd, enum pd_sop_type sop, u8 *buf, size_t len) { Loading Loading @@ -1145,6 +1154,13 @@ static void phy_msg_received(struct usbpd *pd, enum pd_sop_type sop, return; } if (pd->vdm_in_suspend && msg_type == MSG_VDM) { usbpd_dbg(&pd->dev, "Skip wq and handle VDM directly\n"); handle_vdm_rx(pd, rx_msg); kfree(rx_msg); return; } spin_lock_irqsave(&pd->rx_lock, flags); list_add_tail(&rx_msg->entry, &pd->rx_q); spin_unlock_irqrestore(&pd->rx_lock, flags); Loading Loading @@ -1272,6 +1288,7 @@ static void reset_vdm_state(struct usbpd *pd) kfree(pd->vdm_tx); pd->vdm_tx = NULL; pd->ss_lane_svid = 0x0; pd->vdm_in_suspend = false; } static inline void rx_msg_cleanup(struct usbpd *pd) Loading Loading @@ -1804,6 +1821,7 @@ int usbpd_send_vdm(struct usbpd *pd, u32 vdm_hdr, const u32 *vdos, int num_vdos) /* VDM will get sent in PE_SRC/SNK_READY state handling */ pd->vdm_tx = vdm_tx; pd->vdm_in_suspend = false; /* slight delay before queuing to prioritize handling of incoming VDM */ if (pd->in_explicit_contract) Loading @@ -1826,6 +1844,14 @@ int usbpd_send_svdm(struct usbpd *pd, u16 svid, u8 cmd, } EXPORT_SYMBOL(usbpd_send_svdm); void usbpd_vdm_in_suspend(struct usbpd *pd, bool in_suspend) { usbpd_dbg(&pd->dev, "VDM in_suspend:%d\n", in_suspend); pd->vdm_in_suspend = in_suspend; } EXPORT_SYMBOL(usbpd_vdm_in_suspend); static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg) { int ret; Loading include/linux/usb/usbpd.h +5 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -105,6 +105,8 @@ int usbpd_send_svdm(struct usbpd *pd, u16 svid, u8 cmd, * otherwise ORIENTATION_NONE if not attached */ enum plug_orientation usbpd_get_plug_orientation(struct usbpd *pd); void usbpd_vdm_in_suspend(struct usbpd *pd, bool in_suspend); #else static inline struct usbpd *devm_usbpd_get_by_phandle(struct device *dev, const char *phandle) Loading Loading @@ -140,6 +142,8 @@ static inline enum plug_orientation usbpd_get_plug_orientation(struct usbpd *pd) { return ORIENTATION_NONE; } static inline void usbpd_vdm_in_suspend(struct usbpd *pd, bool in_suspend) { } #endif /* IS_ENABLED(CONFIG_USB_PD_POLICY) */ /* Loading Loading
drivers/usb/pd/policy_engine.c +29 −3 Original line number Diff line number Diff line Loading @@ -463,6 +463,7 @@ struct usbpd { struct mutex svid_handler_lock; struct list_head svid_handlers; ktime_t svdm_start_time; bool vdm_in_suspend; struct list_head instance; Loading Loading @@ -658,15 +659,21 @@ static struct usbpd_svid_handler *find_svid_handler(struct usbpd *pd, u16 svid) { struct usbpd_svid_handler *handler; /* in_interrupt() == true when handling VDM RX during suspend */ if (!in_interrupt()) mutex_lock(&pd->svid_handler_lock); list_for_each_entry(handler, &pd->svid_handlers, entry) { if (svid == handler->svid) { if (!in_interrupt()) mutex_unlock(&pd->svid_handler_lock); return handler; } } if (!in_interrupt()) mutex_unlock(&pd->svid_handler_lock); return NULL; } Loading Loading @@ -1073,6 +1080,8 @@ static struct rx_msg *pd_ext_msg_received(struct usbpd *pd, u16 header, u8 *buf, return rx_msg; /* queue it for usbpd_sm */ } static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg); static void phy_msg_received(struct usbpd *pd, enum pd_sop_type sop, u8 *buf, size_t len) { Loading Loading @@ -1145,6 +1154,13 @@ static void phy_msg_received(struct usbpd *pd, enum pd_sop_type sop, return; } if (pd->vdm_in_suspend && msg_type == MSG_VDM) { usbpd_dbg(&pd->dev, "Skip wq and handle VDM directly\n"); handle_vdm_rx(pd, rx_msg); kfree(rx_msg); return; } spin_lock_irqsave(&pd->rx_lock, flags); list_add_tail(&rx_msg->entry, &pd->rx_q); spin_unlock_irqrestore(&pd->rx_lock, flags); Loading Loading @@ -1272,6 +1288,7 @@ static void reset_vdm_state(struct usbpd *pd) kfree(pd->vdm_tx); pd->vdm_tx = NULL; pd->ss_lane_svid = 0x0; pd->vdm_in_suspend = false; } static inline void rx_msg_cleanup(struct usbpd *pd) Loading Loading @@ -1804,6 +1821,7 @@ int usbpd_send_vdm(struct usbpd *pd, u32 vdm_hdr, const u32 *vdos, int num_vdos) /* VDM will get sent in PE_SRC/SNK_READY state handling */ pd->vdm_tx = vdm_tx; pd->vdm_in_suspend = false; /* slight delay before queuing to prioritize handling of incoming VDM */ if (pd->in_explicit_contract) Loading @@ -1826,6 +1844,14 @@ int usbpd_send_svdm(struct usbpd *pd, u16 svid, u8 cmd, } EXPORT_SYMBOL(usbpd_send_svdm); void usbpd_vdm_in_suspend(struct usbpd *pd, bool in_suspend) { usbpd_dbg(&pd->dev, "VDM in_suspend:%d\n", in_suspend); pd->vdm_in_suspend = in_suspend; } EXPORT_SYMBOL(usbpd_vdm_in_suspend); static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg) { int ret; Loading
include/linux/usb/usbpd.h +5 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -105,6 +105,8 @@ int usbpd_send_svdm(struct usbpd *pd, u16 svid, u8 cmd, * otherwise ORIENTATION_NONE if not attached */ enum plug_orientation usbpd_get_plug_orientation(struct usbpd *pd); void usbpd_vdm_in_suspend(struct usbpd *pd, bool in_suspend); #else static inline struct usbpd *devm_usbpd_get_by_phandle(struct device *dev, const char *phandle) Loading Loading @@ -140,6 +142,8 @@ static inline enum plug_orientation usbpd_get_plug_orientation(struct usbpd *pd) { return ORIENTATION_NONE; } static inline void usbpd_vdm_in_suspend(struct usbpd *pd, bool in_suspend) { } #endif /* IS_ENABLED(CONFIG_USB_PD_POLICY) */ /* Loading