diff mbox series

[3/7] core/pci: Introduce a new pci_slot_op named completed_sm_run()

Message ID 20180915143926.12870-4-vaibhav@linux.ibm.com
State Changes Requested
Headers show
Series Enable fast-reboot support for CAPI-2 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Vaibhav Jain Sept. 15, 2018, 2:39 p.m. UTC
At times we need to perform some cleanup activities when the Opal PCI
state machine that perform creset/freset/hreset (driven by
pci_slot_ops->run_sm which) of a slot completes. One example can be to
mark CAPP attached to a PHB, as deactivated when creset/freset of a
CAPI card slot is completed.

However the calls to pci_slot_ops->run_sm() is scattered through out
the code and patching each call site to check for the return value and
perform custom cleanup tacks is difficult.

Hence this patch introduces a new pci_slot_ops named
completed_sm_run() which should be called when pci_slot_ops->run_sm()
determines that the reset state machine is complete. This provides a
more centralized way to handle slot related cleanup activities.

Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 core/pci-slot.c    | 6 +++++-
 include/pci-slot.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Andrew Donnellan Sept. 17, 2018, 7:50 a.m. UTC | #1
On 16/9/18 12:39 am, Vaibhav Jain wrote:
> At times we need to perform some cleanup activities when the Opal PCI
> state machine that perform creset/freset/hreset (driven by
> pci_slot_ops->run_sm which) of a slot completes. One example can be to
> mark CAPP attached to a PHB, as deactivated when creset/freset of a
> CAPI card slot is completed.
> 
> However the calls to pci_slot_ops->run_sm() is scattered through out
> the code and patching each call site to check for the return value and
> perform custom cleanup tacks is difficult.
> 
> Hence this patch introduces a new pci_slot_ops named
> completed_sm_run() which should be called when pci_slot_ops->run_sm()
> determines that the reset state machine is complete. This provides a
> more centralized way to handle slot related cleanup activities.
> 
> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
> ---
>   core/pci-slot.c    | 6 +++++-
>   include/pci-slot.h | 1 +
>   2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/core/pci-slot.c b/core/pci-slot.c
> index 71d2769e..497d0a47 100644
> --- a/core/pci-slot.c
> +++ b/core/pci-slot.c
> @@ -104,9 +104,13 @@ static int64_t pci_slot_run_sm(struct pci_slot *slot)
>   		prlog(PR_ERR, PCI_SLOT_PREFIX
>   		      "Invalid state %08x\n", slot->id, slot->state);
>   		pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL);
> -		return OPAL_HARDWARE;
> +		ret = OPAL_HARDWARE;
>   	}
>   
> +	/* Notify about the pci slot state machine completion */
> +	if (ret <= 0 && slot->ops.completed_sm_run)
> +		slot->ops.completed_sm_run(slot, ret);
> +
>   	return ret;
>   }
>   
> diff --git a/include/pci-slot.h b/include/pci-slot.h
> index cd757535..f3fe0d1d 100644
> --- a/include/pci-slot.h
> +++ b/include/pci-slot.h
> @@ -110,6 +110,7 @@ struct pci_slot_ops {
>   	int64_t (*freset)(struct pci_slot *slot);
>   	int64_t (*hreset)(struct pci_slot *slot);
>   	int64_t (*run_sm)(struct pci_slot *slot);
> +	void (*completed_sm_run)(struct pci_slot *slot, uint64_t err);

Is there a reason this can't be an int64_t like the others? I mean, I'm 
not sure what kind of failures we'd report...

This seems a good idea to me, so:

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

>   
>   	/* Auxillary functions */
>   	void (*add_properties)(struct pci_slot *slot, struct dt_node *np);
>
Vaibhav Jain Sept. 17, 2018, 9:12 a.m. UTC | #2
Thanks for reviewing this patch Andrew:

Andrew Donnellan <andrew.donnellan@au1.ibm.com> writes:
>>   	int64_t (*run_sm)(struct pci_slot *slot);
>> +	void (*completed_sm_run)(struct pci_slot *slot, uint64_t err);
>
> Is there a reason this can't be an int64_t like the others? I mean, I'm 
> not sure what kind of failures we'd report...
Go idea, This can return a int64_t so that any slot cleanup errors be
communicated back. It was also override an error messages reported
during the reset.

> This seems a good idea to me, so:
> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Thanks
diff mbox series

Patch

diff --git a/core/pci-slot.c b/core/pci-slot.c
index 71d2769e..497d0a47 100644
--- a/core/pci-slot.c
+++ b/core/pci-slot.c
@@ -104,9 +104,13 @@  static int64_t pci_slot_run_sm(struct pci_slot *slot)
 		prlog(PR_ERR, PCI_SLOT_PREFIX
 		      "Invalid state %08x\n", slot->id, slot->state);
 		pci_slot_set_state(slot, PCI_SLOT_STATE_NORMAL);
-		return OPAL_HARDWARE;
+		ret = OPAL_HARDWARE;
 	}
 
+	/* Notify about the pci slot state machine completion */
+	if (ret <= 0 && slot->ops.completed_sm_run)
+		slot->ops.completed_sm_run(slot, ret);
+
 	return ret;
 }
 
diff --git a/include/pci-slot.h b/include/pci-slot.h
index cd757535..f3fe0d1d 100644
--- a/include/pci-slot.h
+++ b/include/pci-slot.h
@@ -110,6 +110,7 @@  struct pci_slot_ops {
 	int64_t (*freset)(struct pci_slot *slot);
 	int64_t (*hreset)(struct pci_slot *slot);
 	int64_t (*run_sm)(struct pci_slot *slot);
+	void (*completed_sm_run)(struct pci_slot *slot, uint64_t err);
 
 	/* Auxillary functions */
 	void (*add_properties)(struct pci_slot *slot, struct dt_node *np);