[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 03/15] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLE
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v3 03/15] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED transition |
Date: |
Thu, 9 Feb 2023 23:07:56 +0300 |
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>
---
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 ((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) {
+ if (state != SHPC_STATE_NO) {
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. */
--
2.34.1
- [PATCH v3 00/15] pci hotplug tracking, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 05/15] pci/shpc: pass PCIDevice pointer to shpc_slot_command(), Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 04/15] pci/shpc: more generic handle hot-unplug in shpc_slot_command(), Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 02/15] pci/shpc: change shpc_get_status() return type to uint8_t, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 06/15] pcie: pcie_cap_slot_write_config(): use correct macro, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 08/15] pcie: drop unused PCIExpressIndicator, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 10/15] pcie: introduce pcie_sltctl_powered_off() helper, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 03/15] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED transition,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v3 07/15] pcie_regs: drop duplicated indicator value macros, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 01/15] pci/shpc: set attention led to OFF on reset, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 09/15] pcie: pcie_cap_slot_enable_power() use correct helper, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 11/15] pcie: set power indicator to off on reset by default, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 15/15] qapi: introduce query-hotplug command, Vladimir Sementsov-Ogievskiy, 2023/02/09
- [PATCH v3 13/15] qapi: add HOTPLUG_STATE event, Vladimir Sementsov-Ogievskiy, 2023/02/09