From nobody Tue Feb 10 06:43:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1676296968; cv=none; d=zohomail.com; s=zohoarc; b=NEE8prw9wBm6d37jCNb0NxxuvikfY5XwGKE1Bx56+y0GB25MtWl2sl7WvQby2omE4PYnyAZ9dKx4i1St7gP2lSn45O7qFYlrVdK8vTRhoeXjEvhcH18/WN59f+e3beWGmsz9Co58WP1l8EOWAiS64ultrrXL/zL0KtARTce+w50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676296968; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MMa6nDioTx3cGuqWVQFeRTH8JsSLdlX2olYFCTFUFVU=; b=X3RY4tpmRzmhrc+iXk1cXudAHKbCLWU6WG+e/GwfGEg1pX+mfgr+x0zHONWepLdie4ISeu/Nb0Fs5XC3ZiUdZE0OHKge8Ul3h3HA8AEeC1qxB0zsR6QAgKkH2Xcqkn7FBCKy7esZYMjp5JUBYwNUnBXJ7cGofD1YhGxWuA2CGkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676296968339483.4726134936817; Mon, 13 Feb 2023 06:02:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRZP0-0006iP-0E; Mon, 13 Feb 2023 09:01:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRZOa-0006bh-CN for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:01:37 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRZOS-0005sc-Op for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:01:22 -0500 Received: from myt6-23a5e62c0090.qloud-c.yandex.net (myt6-23a5e62c0090.qloud-c.yandex.net [IPv6:2a02:6b8:c12:1da3:0:640:23a5:e62c]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id E6AA061FE4; Mon, 13 Feb 2023 17:01:14 +0300 (MSK) Received: from vsementsov-win.yandex-team.ru (unknown [2a02:6b8:b081:6527::1:3a]) by myt6-23a5e62c0090.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 51j9w00QYCg1-Pk3iS5Sf; Mon, 13 Feb 2023 17:01:14 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1676296874; bh=MMa6nDioTx3cGuqWVQFeRTH8JsSLdlX2olYFCTFUFVU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=Ar4JmQqCNaPSNzGu8uszabpp0+w+3M+tHqQZ3VGDaDS+R3wxQmhpyu3XGyHcQ+ZpV WJb6KGJoNmEc2bKAVbaBqX1A5vp3UcxxMmxTS4uiM7iujwfo5ZluoSDnQqPytJxdbz efmfXFMhPyYBJ5/GysPI7Xm/Cs+UtHXHbDyPfYH0= Authentication-Results: myt6-23a5e62c0090.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: armbru@redhat.com, eblake@redhat.com, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, marcel.apfelbaum@gmail.com, mst@redhat.com, philmd@linaro.org, vsementsov@yandex-team.ru, den-plotnikov@yandex-team.ru, antonkuchin@yandex-team.ru Subject: [PATCH v4 03/16] pci/shpc: shpc_slot_command(): handle PWRONLY -> ENABLED transition Date: Mon, 13 Feb 2023 17:00:50 +0300 Message-Id: <20230213140103.1518173-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213140103.1518173-1-vsementsov@yandex-team.ru> References: <20230213140103.1518173-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1676296994161100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Anton Kuchin --- 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; } =20 - switch (power) { - case SHPC_LED_NO: - break; - default: + if (power !=3D 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 !=3D SHPC_LED_NO) { /* TODO: send event to monitor */ shpc_set_status(shpc, slot, attn, SHPC_SLOT_ATTN_LED_MASK); } - - if ((current_state =3D=3D SHPC_STATE_DISABLED && state =3D=3D SHPC_STA= TE_PWRONLY) || - (current_state =3D=3D SHPC_STATE_DISABLED && state =3D=3D SHPC_STA= TE_ENABLED)) { - shpc_set_status(shpc, slot, state, SHPC_SLOT_STATE_MASK); - } else if ((current_state =3D=3D SHPC_STATE_ENABLED || - current_state =3D=3D SHPC_STATE_PWRONLY) && - state =3D=3D SHPC_STATE_DISABLED) { + if (state !=3D SHPC_STATE_NO) { shpc_set_status(shpc, slot, state, SHPC_SLOT_STATE_MASK); + } + + if ((current_state =3D=3D SHPC_STATE_ENABLED || + current_state =3D=3D SHPC_STATE_PWRONLY) && + state =3D=3D SHPC_STATE_DISABLED) + { power =3D 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.= */ --=20 2.34.1