usb: pd: Clear vdm_tx if SVDM message is sent on SOP'

Consider a case where SVDM message sent on SOP' failed
before starting the power negotiation with the sink.
Currently pd driver will not be freeing vdm_tx and
will be kept around till we reach PE_SRC_Ready state. Now
the same will be sent on SOP instead of SOP' and also with
wrong SVDM version which was kept for the first SVDM msg,
because of Commit I0bafb619e0a("usb: pd: Correctly handle
SVDM versions), causing the other partner to NAK it.

Fix this by clearing the vdm_tx if SVDM message is sent
on SOP'(intended of e-mark cable) which has been failed.

Change-Id: I729a66058ea8829625185483cbec87b435ee66fc
Signed-off-by: Pratham Pratap <prathampratap@codeaurora.org>
This commit is contained in:
Pratham Pratap 2021-08-18 13:57:34 +05:30
parent 1c2af547a0
commit 742d9706e3

View file

@ -1721,8 +1721,12 @@ static void handle_vdm_tx(struct usbpd *pd, enum pd_sop_type sop_type)
mutex_unlock(&pd->svid_handler_lock);
/* retry when hitting PE_SRC/SNK_Ready again */
if (ret != -EBUSY && sop_type == SOP_MSG)
if (ret != -EBUSY && sop_type == SOP_MSG) {
usbpd_set_state(pd, PE_SEND_SOFT_RESET);
} else if (sop_type != SOP_MSG) {
kfree(pd->vdm_tx);
pd->vdm_tx = NULL;
}
return;
}