Skip to contentSkip to conversation

examples/power: fix ack for enable/disable turbo

PATCH Applied David Hunt 3 participants 3 messages Feb 11, 2020 – Feb 13, 2020

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 examples/power: fix ack for enable/disable turbo

When a VM sends a command through virtio-serial to enable/disable turbo, it is successfully enabled or disabled, yet the response to the VM is NACK. This is because all the library frequency change APIs return 1 for success (change in frequency), 0 for success (no change in frequency) and -1 for failure. However the turbo enable/disable APIs just return 0 for success and -1 for failure.

Fix the handling of the return code to treat ">= 0" as success, and send an ACK. Only send NACK when < 0 (failure).

Fixes 0de94bcac7fc ("examples/vm_power: send confirmation cmd to guest")
---
 examples/vm_power_manager/channel_monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +1 -1
index 090c2a98b..1d00a6cf6 100644
@@ -868,7 +868,7 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)
 		if (valid_unit) {
 			ret = send_ack_for_received_cmd(pkt,
 					chan_info,
-					scale_res > 0 ?
+					scale_res >= 0 ?
 						CPU_POWER_CMD_ACK :
 						CPU_POWER_CMD_NACK);
 			if (ret < 0)
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines

-----Original Message-----
From: Hunt, David <[email protected]>
Sent: Tuesday, February 11, 2020 6:50 PM
To: [email protected]; Hunt, David <[email protected]>
Cc: Yao, Lei A <[email protected]>; [email protected]
Subject: [PATCH] examples/power: fix ack for enable/disable turbo

When a VM sends a command through virtio-serial to enable/disable turbo, it is successfully enabled or disabled, yet the response to the VM is NACK. This is because all the library frequency change APIs return
1 for success (change in frequency), 0 for success (no change in frequency) and -1 for failure. However the turbo enable/disable APIs just return 0 for success and -1 for failure.

Quoted 6 lines

Fix the handling of the return code to treat ">= 0" as success, and send an ACK. Only send NACK when < 0 (failure).

Fixes 0de94bcac7fc ("examples/vm_power: send confirmation cmd to

guest")

Quoted 21 lines
---
 examples/vm_power_manager/channel_monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +1 -1
index 090c2a98b..1d00a6cf6 100644
@@ -868,7 +868,7 @@ process_request(struct channel_packet *pkt, struct
 channel_info *chan_info)
 		if (valid_unit) {
 			ret = send_ack_for_received_cmd(pkt,
 					chan_info,
-					scale_res > 0 ?
+					scale_res >= 0 ?
 						CPU_POWER_CMD_ACK :
 						CPU_POWER_CMD_NACK);

if (ret < 0)
--
2.17.1

Acked-by Lei Yao on v1 1/1 Applied
#2 lore raw
In reply to David Hunt
Quoted 11 lines · David Hunt

When a VM sends a command through virtio-serial to enable/disable turbo, it is successfully enabled or disabled, yet the response to the VM is NACK. This is because all the library frequency change APIs return 1 for success (change in frequency), 0 for success (no change in frequency) and -1 for failure. However the turbo enable/disable APIs just return 0 for success and -1 for failure.

Fix the handling of the return code to treat ">= 0" as success, and send an ACK. Only send NACK when < 0 (failure).

Fixes 0de94bcac7fc ("examples/vm_power: send confirmation cmd to guest")
Quoted 1 line

Applied, thanks.

Signature · 1 line
David Marchand