linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Rongguang Wei <clementwei90@163.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	Rongguang Wei <weirongguang@kylinos.cn>
Subject: Re: [PATCH v3] PCI: pciehp: Fix the slot in BLINKINGON_STATE when Presence Detect Changed event occurred
Date: Thu, 11 May 2023 16:43:48 +0200	[thread overview]
Message-ID: <20230511144348.GA4908@wunner.de> (raw)
In-Reply-To: <1b107c50-44a0-2fac-72ee-7ef5d2212924@163.com>

On Fri, May 05, 2023 at 09:38:59AM +0800, Rongguang Wei wrote:
> On 4/29/23 10:30 PM, Lukas Wunner wrote:
> > On Fri, Apr 21, 2023 at 10:56:41AM +0800, Rongguang Wei wrote:
> > > --- 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 = OFF_STATE;
> > >  		mutex_unlock(&ctrl->state_lock);
> > >  		return;
> > >  	}
> > 
> > It has occurred to me that we also need to turn off the Power Indicator,
> > lest it continues blinking after the 5 second interval.  Sorry for not
> > spotting this earlier.  And I'm thinking that making the state change
> > conditional on BLINKINGON_STATE would serve clarity.
> > 
> > So could you please amend the above as follows and verify it fixes the
> > issue for you?
> 
> It works fine.
> 
> >  	if (present <= 0 && link_active <= 0) {
> > +		if (ctrl->state == BLINKINGON_STATE) {
> 
> I have a little question and is there necessary to add
> "cancel_delayed_work(&ctrl->button_work);" here?

Right, that seems reasonable.  pciehp_queue_pushbutton_work() becomes
a no-op once the state has been changed to OFF_STATE, so there's no
real harm if the work item is left in the queue, but canceling it is
definitely cleaner.

And a message to the user might be helpful as well to indicate that
the button press hasn't resulted in slot bringup due to it being
empty.  So maybe something like the below?


diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 529c34808440..32baba1b7f13 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -256,6 +256,14 @@ 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) {
+		if (ctrl->state == BLINKINGON_STATE) {
+			ctrl->state = OFF_STATE;
+			cancel_delayed_work(&ctrl->button_work);
+			pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF,
+					      INDICATOR_NOOP);
+			ctrl_info(ctrl, "Slot(%s): Card not present\n",
+				  slot_name(ctrl));
+		}
 		mutex_unlock(&ctrl->state_lock);
 		return;
 	}

  reply	other threads:[~2023-05-11 14:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21  2:56 [PATCH v3] PCI: pciehp: Fix the slot in BLINKINGON_STATE when Presence Detect Changed event occurred Rongguang Wei
2023-04-29 14:30 ` Lukas Wunner
2023-05-05  1:38   ` Rongguang Wei
2023-05-11 14:43     ` Lukas Wunner [this message]
2023-05-12  1:30       ` 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=20230511144348.GA4908@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).