hv_utils: drain the timesync packets on onchannelcallback
PATCH 1/1 hv_utils: drain the timesync packets on onchannelcallback
From: Vineeth Pillai <[email protected]>
commit b46b4a8a57c377b72a98c7930a9f6969d2d4784e
There could be instances where a system stall prevents the timesync packets to be consumed. And this might lead to more than one packet pending in the ring buffer. Current code empties one packet per callback and it might be a stale one. So drain all the packets from ring buffer on each callback.
The old code in the upstream commit uses HV_HYP_PAGE_SIZE, but the old code in 5.4.y sitll uses PAGE_SIZE. Fixed this manually for 5.4.y.
Note: 5.4.y already has the define HV_HYP_PAGE_SIZE, so the new code in in the upstream commit works for 5.4.y.
If there are multiple messages in the host-to-guest ringbuffer of the TimeSync device, 5.4.y only handles 1 message, and later the host puts new messages into the ringbuffer without signaling the guest because the ringbuffer is not empty, causing a "hung" ringbuffer. Backported the mainline fix for this issue.
--- drivers/hv/hv_util.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/hv/hv_util.c +16 -3
@@ -283,10 +283,23 @@ static void timesync_onchannelcallback(void *context)struct ictimesync_ref_data *refdata;u8 *time_txf_buf = util_timesynch.recv_buffer; -vmbus_recvpacket (channel, time_txf_buf, -PAGE_SIZE , &recvlen, &requestid); +/* +* Drain the ring buffer and use the last packet to update +* host_ts +*/ +while (1 ) { +int ret =vmbus_recvpacket (channel, time_txf_buf, +HV_HYP_PAGE_SIZE , &recvlen, + &requestid); +if (ret) { +pr_warn_once ("TimeSync IC pkt recv failed (Err: %d)\n" , + ret); +break ; + } + +if (!recvlen) +break ; -if (recvlen >0 ) { icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[sizeof (struct vmbuspipe_hdr )];
Signature · 1 line
2.25.1
Quoted 20 lines · Dexuan Cui
From: Vineeth Pillai <[email protected]>
commit
b46b4a8a57c377b72a98c7930a9f6969d2d4784eThere could be instances where a system stall prevents the timesync packets to be consumed. And this might lead to more than one packet pending in the ring buffer. Current code empties one packet per callback and it might be a stale one. So drain all the packets from ring buffer on each callback.
Signed-off-by Vineeth Pillai <[email protected]>Reviewed-by Michael Kelley <[email protected]>Signed-off-by Wei Liu <[email protected]>The old code in the upstream commit uses
HV_HYP_PAGE_SIZE, but the old code in 5.4.y sitll usesPAGE_SIZE. Fixed this manually for 5.4.y.
Note: 5.4.y already has the defineHV_HYP_PAGE_SIZE, so the new code in in the upstream commit works for 5.4.y.
Quoted 6 lines
If there are multiple messages in the host-to-guest ringbuffer of the TimeSync device, 5.4.y only handles 1 message, and later the host puts new messages into the ringbuffer without signaling the guest because the ringbuffer is not empty, causing a "hung" ringbuffer. Backported the mainline fix for this issue.
Signed-off-by Dexuan Cui <[email protected]>
Both now queued up, thanks.
greg k-h