[07/11] pci/hotplug/pnv-php: Improve error msg on power state change failure
diff mbox series

Message ID 20190909154600.19917-8-fbarrat@linux.ibm.com
State New
Headers show
Series
  • opencapi: enable card reset and link retraining
Related show

Checks

Context Check Description
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (c317052c95bef1f977b023158e5aa929215f443d)

Commit Message

Frederic Barrat Sept. 9, 2019, 3:45 p.m. UTC
When changing the slot state, if opal hits an error and tells as such
in the asynchronous reply, the warning "Wrong msg" is logged, which is
rather confusing. Instead we can reuse the better message which is
already used when we couldn't submit the asynchronous opal request
initially.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 drivers/pci/hotplug/pnv_php.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Alastair D'Silva Sept. 10, 2019, 12:59 a.m. UTC | #1
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
> When changing the slot state, if opal hits an error and tells as such
> in the asynchronous reply, the warning "Wrong msg" is logged, which
> is
> rather confusing. Instead we can reuse the better message which is
> already used when we couldn't submit the asynchronous opal request
> initially.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---
>  drivers/pci/hotplug/pnv_php.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pnv_php.c
> b/drivers/pci/hotplug/pnv_php.c
> index 5b5cbf1e636d..304bdbcdb77c 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -336,18 +336,19 @@ int pnv_php_set_slot_power_state(struct
> hotplug_slot *slot,
>  	ret = pnv_pci_set_power_state(php_slot->id, state, &msg);
>  	if (ret > 0) {
>  		if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle
> 	||
> -		    be64_to_cpu(msg.params[2]) != state			
> ||
> -		    be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
> +		    be64_to_cpu(msg.params[2]) != state) {
>  			pci_warn(php_slot->pdev, "Wrong msg (%lld,
> %lld, %lld)\n",
>  				 be64_to_cpu(msg.params[1]),
>  				 be64_to_cpu(msg.params[2]),
>  				 be64_to_cpu(msg.params[3]));
>  			return -ENOMSG;
>  		}
> +		if (be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
> +			ret = -ENODEV;
> +			goto error;
> +		}
>  	} else if (ret < 0) {
> -		pci_warn(php_slot->pdev, "Error %d powering %s\n",
> -			 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on"
> : "off");
> -		return ret;
> +		goto error;
>  	}
>  
>  	if (state == OPAL_PCI_SLOT_POWER_OFF || state ==
> OPAL_PCI_SLOT_OFFLINE)
> @@ -356,6 +357,11 @@ int pnv_php_set_slot_power_state(struct
> hotplug_slot *slot,
>  		ret = pnv_php_add_devtree(php_slot);
>  
>  	return ret;
> +
> +error:
> +	pci_warn(php_slot->pdev, "Error %d powering %s\n",
> +		 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" :
> "off");
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(pnv_php_set_slot_power_state);
>  

Reviewed-by: Alastair D'Silva <alastair@d-silva.org>

Patch
diff mbox series

diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index 5b5cbf1e636d..304bdbcdb77c 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -336,18 +336,19 @@  int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
 	ret = pnv_pci_set_power_state(php_slot->id, state, &msg);
 	if (ret > 0) {
 		if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle	||
-		    be64_to_cpu(msg.params[2]) != state			||
-		    be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
+		    be64_to_cpu(msg.params[2]) != state) {
 			pci_warn(php_slot->pdev, "Wrong msg (%lld, %lld, %lld)\n",
 				 be64_to_cpu(msg.params[1]),
 				 be64_to_cpu(msg.params[2]),
 				 be64_to_cpu(msg.params[3]));
 			return -ENOMSG;
 		}
+		if (be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
+			ret = -ENODEV;
+			goto error;
+		}
 	} else if (ret < 0) {
-		pci_warn(php_slot->pdev, "Error %d powering %s\n",
-			 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off");
-		return ret;
+		goto error;
 	}
 
 	if (state == OPAL_PCI_SLOT_POWER_OFF || state == OPAL_PCI_SLOT_OFFLINE)
@@ -356,6 +357,11 @@  int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
 		ret = pnv_php_add_devtree(php_slot);
 
 	return ret;
+
+error:
+	pci_warn(php_slot->pdev, "Error %d powering %s\n",
+		 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off");
+	return ret;
 }
 EXPORT_SYMBOL_GPL(pnv_php_set_slot_power_state);