Loading drivers/usb/pd/policy_engine.c +46 −14 Original line number Original line Diff line number Diff line Loading @@ -1766,8 +1766,14 @@ static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg) /* Unstructured VDM */ /* Unstructured VDM */ if (!VDM_IS_SVDM(vdm_hdr)) { if (!VDM_IS_SVDM(vdm_hdr)) { if (handler && handler->vdm_received) if (handler && handler->vdm_received) { handler->vdm_received(handler, vdm_hdr, vdos, num_vdos); handler->vdm_received(handler, vdm_hdr, vdos, num_vdos); } else if (pd->spec_rev == USBPD_REV_30) { ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, SOP_MSG); if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); } return; return; } } Loading @@ -1789,8 +1795,17 @@ static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg) switch (cmd_type) { switch (cmd_type) { case SVDM_CMD_TYPE_INITIATOR: case SVDM_CMD_TYPE_INITIATOR: if (cmd != USBPD_SVDM_ATTENTION) { if (cmd != USBPD_SVDM_ATTENTION) { usbpd_send_svdm(pd, svid, cmd, SVDM_CMD_TYPE_RESP_NAK, if (pd->spec_rev == USBPD_REV_30) { SVDM_HDR_OBJ_POS(vdm_hdr), NULL, 0); ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, SOP_MSG); if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); } else { usbpd_send_svdm(pd, svid, cmd, SVDM_CMD_TYPE_RESP_NAK, SVDM_HDR_OBJ_POS(vdm_hdr), NULL, 0); } } } break; break; Loading Loading @@ -2175,15 +2190,19 @@ static void dr_swap(struct usbpd *pd) usbpd_dbg(&pd->dev, "%s: current_dr(%d)\n", __func__, pd->current_dr); usbpd_dbg(&pd->dev, "%s: current_dr(%d)\n", __func__, pd->current_dr); if (pd->current_dr == DR_DFP) { if (pd->current_dr == DR_DFP) { pd->current_dr = DR_UFP; pd_phy_update_roles(pd->current_dr, pd->current_pr); stop_usb_host(pd); stop_usb_host(pd); if (pd->peer_usb_comm) if (pd->peer_usb_comm) start_usb_peripheral(pd); start_usb_peripheral(pd); pd->current_dr = DR_UFP; } else if (pd->current_dr == DR_UFP) { } else if (pd->current_dr == DR_UFP) { pd->current_dr = DR_DFP; pd_phy_update_roles(pd->current_dr, pd->current_pr); stop_usb_peripheral(pd); stop_usb_peripheral(pd); if (pd->peer_usb_comm) if (pd->peer_usb_comm) start_usb_host(pd, true); start_usb_host(pd, true); pd->current_dr = DR_DFP; /* ensure host is started before allowing DP */ /* ensure host is started before allowing DP */ extcon_blocking_sync(pd->extcon, EXTCON_USB_HOST, 0); extcon_blocking_sync(pd->extcon, EXTCON_USB_HOST, 0); Loading @@ -2192,7 +2211,6 @@ static void dr_swap(struct usbpd *pd) SVDM_CMD_TYPE_INITIATOR, 0, NULL, 0); SVDM_CMD_TYPE_INITIATOR, 0, NULL, 0); } } pd_phy_update_roles(pd->current_dr, pd->current_pr); dual_role_instance_changed(pd->dual_role); dual_role_instance_changed(pd->dual_role); } } Loading Loading @@ -2651,10 +2669,17 @@ static void usbpd_sm(struct work_struct *w) handle_get_battery_cap(pd, rx_msg); handle_get_battery_cap(pd, rx_msg); } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { handle_get_battery_status(pd, rx_msg); handle_get_battery_status(pd, rx_msg); } else if (rx_msg && pd->spec_rev == USBPD_REV_30) { } else if (IS_CTRL(rx_msg, MSG_ACCEPT) || /* unhandled messages */ IS_CTRL(rx_msg, MSG_REJECT) || ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, IS_CTRL(rx_msg, MSG_WAIT)) { SOP_MSG); usbpd_warn(&pd->dev, "Unexpected message\n"); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; } else if (rx_msg && !IS_CTRL(rx_msg, MSG_NOT_SUPPORTED)) { usbpd_dbg(&pd->dev, "Unsupported message\n"); ret = pd_send_msg(pd, pd->spec_rev == USBPD_REV_30 ? MSG_NOT_SUPPORTED : MSG_REJECT, NULL, 0, SOP_MSG); if (ret) if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; break; Loading Loading @@ -3007,10 +3032,17 @@ static void usbpd_sm(struct work_struct *w) handle_get_battery_cap(pd, rx_msg); handle_get_battery_cap(pd, rx_msg); } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { handle_get_battery_status(pd, rx_msg); handle_get_battery_status(pd, rx_msg); } else if (rx_msg && pd->spec_rev == USBPD_REV_30) { } else if (IS_CTRL(rx_msg, MSG_ACCEPT) || /* unhandled messages */ IS_CTRL(rx_msg, MSG_REJECT) || ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, IS_CTRL(rx_msg, MSG_WAIT)) { SOP_MSG); usbpd_warn(&pd->dev, "Unexpected message\n"); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; } else if (rx_msg && !IS_CTRL(rx_msg, MSG_NOT_SUPPORTED)) { usbpd_dbg(&pd->dev, "Unsupported message\n"); ret = pd_send_msg(pd, pd->spec_rev == USBPD_REV_30 ? MSG_NOT_SUPPORTED : MSG_REJECT, NULL, 0, SOP_MSG); if (ret) if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; break; Loading Loading
drivers/usb/pd/policy_engine.c +46 −14 Original line number Original line Diff line number Diff line Loading @@ -1766,8 +1766,14 @@ static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg) /* Unstructured VDM */ /* Unstructured VDM */ if (!VDM_IS_SVDM(vdm_hdr)) { if (!VDM_IS_SVDM(vdm_hdr)) { if (handler && handler->vdm_received) if (handler && handler->vdm_received) { handler->vdm_received(handler, vdm_hdr, vdos, num_vdos); handler->vdm_received(handler, vdm_hdr, vdos, num_vdos); } else if (pd->spec_rev == USBPD_REV_30) { ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, SOP_MSG); if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); } return; return; } } Loading @@ -1789,8 +1795,17 @@ static void handle_vdm_rx(struct usbpd *pd, struct rx_msg *rx_msg) switch (cmd_type) { switch (cmd_type) { case SVDM_CMD_TYPE_INITIATOR: case SVDM_CMD_TYPE_INITIATOR: if (cmd != USBPD_SVDM_ATTENTION) { if (cmd != USBPD_SVDM_ATTENTION) { usbpd_send_svdm(pd, svid, cmd, SVDM_CMD_TYPE_RESP_NAK, if (pd->spec_rev == USBPD_REV_30) { SVDM_HDR_OBJ_POS(vdm_hdr), NULL, 0); ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, SOP_MSG); if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); } else { usbpd_send_svdm(pd, svid, cmd, SVDM_CMD_TYPE_RESP_NAK, SVDM_HDR_OBJ_POS(vdm_hdr), NULL, 0); } } } break; break; Loading Loading @@ -2175,15 +2190,19 @@ static void dr_swap(struct usbpd *pd) usbpd_dbg(&pd->dev, "%s: current_dr(%d)\n", __func__, pd->current_dr); usbpd_dbg(&pd->dev, "%s: current_dr(%d)\n", __func__, pd->current_dr); if (pd->current_dr == DR_DFP) { if (pd->current_dr == DR_DFP) { pd->current_dr = DR_UFP; pd_phy_update_roles(pd->current_dr, pd->current_pr); stop_usb_host(pd); stop_usb_host(pd); if (pd->peer_usb_comm) if (pd->peer_usb_comm) start_usb_peripheral(pd); start_usb_peripheral(pd); pd->current_dr = DR_UFP; } else if (pd->current_dr == DR_UFP) { } else if (pd->current_dr == DR_UFP) { pd->current_dr = DR_DFP; pd_phy_update_roles(pd->current_dr, pd->current_pr); stop_usb_peripheral(pd); stop_usb_peripheral(pd); if (pd->peer_usb_comm) if (pd->peer_usb_comm) start_usb_host(pd, true); start_usb_host(pd, true); pd->current_dr = DR_DFP; /* ensure host is started before allowing DP */ /* ensure host is started before allowing DP */ extcon_blocking_sync(pd->extcon, EXTCON_USB_HOST, 0); extcon_blocking_sync(pd->extcon, EXTCON_USB_HOST, 0); Loading @@ -2192,7 +2211,6 @@ static void dr_swap(struct usbpd *pd) SVDM_CMD_TYPE_INITIATOR, 0, NULL, 0); SVDM_CMD_TYPE_INITIATOR, 0, NULL, 0); } } pd_phy_update_roles(pd->current_dr, pd->current_pr); dual_role_instance_changed(pd->dual_role); dual_role_instance_changed(pd->dual_role); } } Loading Loading @@ -2651,10 +2669,17 @@ static void usbpd_sm(struct work_struct *w) handle_get_battery_cap(pd, rx_msg); handle_get_battery_cap(pd, rx_msg); } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { handle_get_battery_status(pd, rx_msg); handle_get_battery_status(pd, rx_msg); } else if (rx_msg && pd->spec_rev == USBPD_REV_30) { } else if (IS_CTRL(rx_msg, MSG_ACCEPT) || /* unhandled messages */ IS_CTRL(rx_msg, MSG_REJECT) || ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, IS_CTRL(rx_msg, MSG_WAIT)) { SOP_MSG); usbpd_warn(&pd->dev, "Unexpected message\n"); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; } else if (rx_msg && !IS_CTRL(rx_msg, MSG_NOT_SUPPORTED)) { usbpd_dbg(&pd->dev, "Unsupported message\n"); ret = pd_send_msg(pd, pd->spec_rev == USBPD_REV_30 ? MSG_NOT_SUPPORTED : MSG_REJECT, NULL, 0, SOP_MSG); if (ret) if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; break; Loading Loading @@ -3007,10 +3032,17 @@ static void usbpd_sm(struct work_struct *w) handle_get_battery_cap(pd, rx_msg); handle_get_battery_cap(pd, rx_msg); } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { } else if (IS_EXT(rx_msg, MSG_GET_BATTERY_STATUS)) { handle_get_battery_status(pd, rx_msg); handle_get_battery_status(pd, rx_msg); } else if (rx_msg && pd->spec_rev == USBPD_REV_30) { } else if (IS_CTRL(rx_msg, MSG_ACCEPT) || /* unhandled messages */ IS_CTRL(rx_msg, MSG_REJECT) || ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0, IS_CTRL(rx_msg, MSG_WAIT)) { SOP_MSG); usbpd_warn(&pd->dev, "Unexpected message\n"); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; } else if (rx_msg && !IS_CTRL(rx_msg, MSG_NOT_SUPPORTED)) { usbpd_dbg(&pd->dev, "Unsupported message\n"); ret = pd_send_msg(pd, pd->spec_rev == USBPD_REV_30 ? MSG_NOT_SUPPORTED : MSG_REJECT, NULL, 0, SOP_MSG); if (ret) if (ret) usbpd_set_state(pd, PE_SEND_SOFT_RESET); usbpd_set_state(pd, PE_SEND_SOFT_RESET); break; break; Loading