[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/53] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED tr
From: |
Michael S. Tsirkin |
Subject: |
[PULL 22/53] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED transition |
Date: |
Thu, 2 Mar 2023 03:25:38 -0500 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
ENABLED -> PWRONLY transition is not allowed and we handle it by
shpc_invalid_command(). But PWRONLY -> ENABLED transition is silently
ignored, which seems wrong. Let's handle it as correct.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Anton Kuchin <antonkuchin@yandex-team.ru>
Message-Id: <20230216180356.156832-4-vsementsov@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci/shpc.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index 5d71569b13..25e4172382 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -273,28 +273,22 @@ static void shpc_slot_command(SHPCDevice *shpc, uint8_t
target,
return;
}
- switch (power) {
- case SHPC_LED_NO:
- break;
- default:
+ if (power != SHPC_LED_NO) {
/* TODO: send event to monitor */
shpc_set_status(shpc, slot, power, SHPC_SLOT_PWR_LED_MASK);
}
- switch (attn) {
- case SHPC_LED_NO:
- break;
- default:
+ if (attn != SHPC_LED_NO) {
/* TODO: send event to monitor */
shpc_set_status(shpc, slot, attn, SHPC_SLOT_ATTN_LED_MASK);
}
+ if (state != SHPC_STATE_NO) {
+ shpc_set_status(shpc, slot, state, SHPC_SLOT_STATE_MASK);
+ }
- if ((current_state == SHPC_STATE_DISABLED && state == SHPC_STATE_PWRONLY)
||
- (current_state == SHPC_STATE_DISABLED && state == SHPC_STATE_ENABLED))
{
- shpc_set_status(shpc, slot, state, SHPC_SLOT_STATE_MASK);
- } else if ((current_state == SHPC_STATE_ENABLED ||
- current_state == SHPC_STATE_PWRONLY) &&
- state == SHPC_STATE_DISABLED) {
- shpc_set_status(shpc, slot, state, SHPC_SLOT_STATE_MASK);
+ if ((current_state == SHPC_STATE_ENABLED ||
+ current_state == SHPC_STATE_PWRONLY) &&
+ state == SHPC_STATE_DISABLED)
+ {
power = shpc_get_status(shpc, slot, SHPC_SLOT_PWR_LED_MASK);
/* TODO: track what monitor requested. */
/* Look at LED to figure out whether it's ok to remove the device. */
--
MST
- Re: [PULL 14/53] virtio-rng-pci: fix transitional migration compat for vectors, (continued)
- [PULL 08/53] Revert "hw/i386: pass RNG seed via setup_data entry", Michael S. Tsirkin, 2023/03/02
- [PULL 15/53] hw/timer/hpet: Fix expiration time overflow, Michael S. Tsirkin, 2023/03/02
- [PULL 06/53] Revert "x86: use typedef for SetupData struct", Michael S. Tsirkin, 2023/03/02
- [PULL 18/53] vhost-user: Adopt new backend naming, Michael S. Tsirkin, 2023/03/02
- [PULL 19/53] vdpa: stop all svq on device deletion, Michael S. Tsirkin, 2023/03/02
- [PULL 20/53] pci/shpc: set attention led to OFF on reset, Michael S. Tsirkin, 2023/03/02
- [PULL 21/53] pci/shpc: change shpc_get_status() return type to uint8_t, Michael S. Tsirkin, 2023/03/02
- [PULL 22/53] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED transition,
Michael S. Tsirkin <=
- [PULL 23/53] pci/shpc: more generic handle hot-unplug in shpc_slot_command(), Michael S. Tsirkin, 2023/03/02
- [PULL 27/53] pcie_regs: drop duplicated indicator value macros, Michael S. Tsirkin, 2023/03/02
- [PULL 24/53] pci/shpc: pass PCIDevice pointer to shpc_slot_command(), Michael S. Tsirkin, 2023/03/02
- [PULL 25/53] pci/shpc: refactor shpc_device_plug_common(), Michael S. Tsirkin, 2023/03/02
- [PULL 26/53] pcie: pcie_cap_slot_write_config(): use correct macro, Michael S. Tsirkin, 2023/03/02
- [PULL 29/53] pcie: pcie_cap_slot_enable_power() use correct helper, Michael S. Tsirkin, 2023/03/02
- [PULL 28/53] pcie: drop unused PCIExpressIndicator, Michael S. Tsirkin, 2023/03/02
- [PULL 31/53] pcie: set power indicator to off on reset by default, Michael S. Tsirkin, 2023/03/02