public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Rongguang Wei <clementwei90@163.com>,
	Rongguang Wei <weirongguang@kylinos.cn>,
	Lukas Wunner <lukas@wunner.de>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH] PCI: pciehp: Simplify Attention Button logging
Date: Mon, 22 May 2023 16:53:57 -0500	[thread overview]
Message-ID: <ZGvkdYD4vRVnYfRg@bhelgaas> (raw)
In-Reply-To: <20230522214051.619337-1-helgaas@kernel.org>

On Mon, May 22, 2023 at 04:40:51PM -0500, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> Previously, pressing the Attention Button always logged two lines, the
> first from pciehp_ist() and the second from pciehp_handle_button_press():
> 
>   Attention button pressed
>   Powering on due to button press
> 
> Since pciehp_handle_button_press() always logs the more detailed message,
> remove the generic "Attention button pressed" message.  Reword the
> pciehp_handle_button_press() to be of the form:
> 
>   Button press: powering on
>   Button press: powering off
>   Button press: canceling poweron
>   Button press: canceling poweroff
>   Button press: ignoring invalid state %#x

If nobody objects to this patch, I'd likely reorder it before your
patch, Rongguang, and update that commit log to mention the new
messages.

> ---
>  drivers/pci/hotplug/pciehp_ctrl.c | 20 +++++++++-----------
>  drivers/pci/hotplug/pciehp_hpc.c  |  5 +----
>  2 files changed, 10 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
> index 32baba1b7f13..ff725104bf2b 100644
> --- a/drivers/pci/hotplug/pciehp_ctrl.c
> +++ b/drivers/pci/hotplug/pciehp_ctrl.c
> @@ -164,15 +164,13 @@ void pciehp_handle_button_press(struct controller *ctrl)
>  	switch (ctrl->state) {
>  	case OFF_STATE:
>  	case ON_STATE:
> -		if (ctrl->state == ON_STATE) {
> +		if (ctrl->state == ON_STATE)
>  			ctrl->state = BLINKINGOFF_STATE;
> -			ctrl_info(ctrl, "Slot(%s): Powering off due to button press\n",
> -				  slot_name(ctrl));
> -		} else {
> +		else
>  			ctrl->state = BLINKINGON_STATE;
> -			ctrl_info(ctrl, "Slot(%s) Powering on due to button press\n",
> -				  slot_name(ctrl));
> -		}
> +		ctrl_info(ctrl, "Slot(%s): Button press: powering %s\n",
> +			  slot_name(ctrl),
> +			  ctrl->state == BLINKINGON_STATE ? "on" : "off");
>  		/* blink power indicator and turn off attention */
>  		pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK,
>  				      PCI_EXP_SLTCTL_ATTN_IND_OFF);
> @@ -185,7 +183,6 @@ void pciehp_handle_button_press(struct controller *ctrl)
>  		 * press the attention again before the 5 sec. limit
>  		 * expires to cancel hot-add or hot-remove
>  		 */
> -		ctrl_info(ctrl, "Slot(%s): Button cancel\n", slot_name(ctrl));
>  		cancel_delayed_work(&ctrl->button_work);
>  		if (ctrl->state == BLINKINGOFF_STATE) {
>  			ctrl->state = ON_STATE;
> @@ -196,11 +193,12 @@ void pciehp_handle_button_press(struct controller *ctrl)
>  			pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF,
>  					      PCI_EXP_SLTCTL_ATTN_IND_OFF);
>  		}
> -		ctrl_info(ctrl, "Slot(%s): Action canceled due to button press\n",
> -			  slot_name(ctrl));
> +		ctrl_info(ctrl, "Slot(%s): Button press: canceling power%s\n",
> +			  slot_name(ctrl),
> +			  ctrl->state == ON_STATE ? "off" : "on");
>  		break;
>  	default:
> -		ctrl_err(ctrl, "Slot(%s): Ignoring invalid state %#x\n",
> +		ctrl_err(ctrl, "Slot(%s): Button press: ignoring invalid state %#x\n",
>  			 slot_name(ctrl), ctrl->state);
>  		break;
>  	}
> diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
> index f8c70115b691..379d2af5c51d 100644
> --- a/drivers/pci/hotplug/pciehp_hpc.c
> +++ b/drivers/pci/hotplug/pciehp_hpc.c
> @@ -722,11 +722,8 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id)
>  	}
>  
>  	/* Check Attention Button Pressed */
> -	if (events & PCI_EXP_SLTSTA_ABP) {
> -		ctrl_info(ctrl, "Slot(%s): Attention button pressed\n",
> -			  slot_name(ctrl));
> +	if (events & PCI_EXP_SLTSTA_ABP)
>  		pciehp_handle_button_press(ctrl);
> -	}
>  
>  	/* Check Power Fault Detected */
>  	if (events & PCI_EXP_SLTSTA_PFD) {
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-05-22 21:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 21:40 [PATCH] PCI: pciehp: Simplify Attention Button logging Bjorn Helgaas
2023-05-22 21:53 ` Bjorn Helgaas [this message]
2023-05-23  5:29 ` Lukas Wunner
2023-05-23 15:40   ` Bjorn Helgaas
2023-05-24 10:08     ` Lukas Wunner
2023-05-24 16:54       ` Bjorn Helgaas

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=ZGvkdYD4vRVnYfRg@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=clementwei90@163.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --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