From: Lukas Wunner <lukas@wunner.de>
To: Rongguang Wei <clementwei90@163.com>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
Rongguang Wei <weirongguang@kylinos.cn>
Subject: Re: [PATCH v1] PCI: pciehp: Fix the slot in BLINKINGON_STATE when Presence Detect Changed event occurred
Date: Sun, 16 Apr 2023 17:18:26 +0200 [thread overview]
Message-ID: <20230416151826.GA13954@wunner.de> (raw)
In-Reply-To: <20230403054619.19163-1-clementwei90@163.com>
On Mon, Apr 03, 2023 at 01:46:19PM +0800, Rongguang Wei wrote:
> When a Presence Detect Changed event has occurred, the slot status
> in either BLINKINGOFF_STATE or OFF_STATE, turn it off unconditionally.
> But if the slot status is in BLINKINGON_STATE and the slot is currently
> empty, the slot status was staying in BLINKINGON_STATE.
>
> The message print like this:
> pcieport 0000:00:01.5: pciehp: Slot(0-5): Attention button pressed
> pcieport 0000:00:01.5: pciehp: Slot(0-5) Powering on due to button press
> pcieport 0000:00:01.5: pciehp: Slot(0-5): Attention button pressed
> pcieport 0000:00:01.5: pciehp: Slot(0-5): Button cancel
> pcieport 0000:00:01.5: pciehp: Slot(0-5): Action canceled due to button press
>
> It cause the next Attention Button Pressed event become Button cancel
> and missing the Presence Detect Changed event with this button press
> though this button presses event is occurred after 5s.
I see what you mean.
pciehp's behavior is incorrect if the Attention Button is pressed
on an unoccupied slot:
Upon a button press, pciehp_queue_pushbutton_work() is scheduled to run
after 5 seconds. It synthesizes a Presence Detect Changed event,
whereupon pciehp_handle_presence_or_link_change() runs.
Should the slot be empty, pciehp_handle_presence_or_link_change() just
bails out and the state incorrectly remains in BLINKINGON_STATE.
> --- a/drivers/pci/hotplug/pciehp_ctrl.c
> +++ b/drivers/pci/hotplug/pciehp_ctrl.c
> @@ -232,6 +232,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
> */
> mutex_lock(&ctrl->state_lock);
> switch (ctrl->state) {
> + case BLINKINGON_STATE:
> case BLINKINGOFF_STATE:
> cancel_delayed_work(&ctrl->button_work);
> fallthrough;
This solution has the disadvantage that a gratuitous "Card not present"
message is emitted even if the slot is occupied.
I'd prefer the following simpler solution:
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 529c348..e680444 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -256,6 +256,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
present = pciehp_card_present(ctrl);
link_active = pciehp_check_link_active(ctrl);
if (present <= 0 && link_active <= 0) {
+ ctrl->state = POWEROFF_STATE;
mutex_unlock(&ctrl->state_lock);
return;
}
Optionally the assignment can be made conditional on
"if (ctrl->state == BLINKINGON_STATE)" for clarity.
Likewise, a "Card not present" message can optionally be emitted here.
Thanks,
Lukas
next prev parent reply other threads:[~2023-04-16 15:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 5:46 [PATCH v1] PCI: pciehp: Fix the slot in BLINKINGON_STATE when Presence Detect Changed event occurred Rongguang Wei
2023-04-10 5:00 ` Rongguang Wei
2023-04-11 18:30 ` Bjorn Helgaas
2023-04-16 15:18 ` Lukas Wunner [this message]
2023-04-17 3:04 ` Rongguang Wei
2023-04-17 7:11 ` Lukas Wunner
2023-04-19 2:58 ` Rongguang Wei
2023-04-19 7:48 ` Lukas Wunner
2023-04-20 9:46 ` Rongguang Wei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230416151826.GA13954@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=clementwei90@163.com \
--cc=linux-pci@vger.kernel.org \
--cc=weirongguang@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.