[Skiboot] [PATCH 4/7] capp/phb4: Force CAPP to PCIe mode during kernel shutdown
Frederic Barrat
fbarrat at linux.ibm.com
Fri Sep 21 22:33:13 AEST 2018
Le 15/09/2018 à 16:39, Vaibhav Jain a écrit :
> This patch introduces a new opal syncer for PHB4 named
> phb4_host_sync_reset(). We register this opal syncer when CAPP is
> activated successfully in phb4_set_capi_mode() so that it will be
> called at kernel shutdown during fast-reset.
>
> The function will then repeatedly call phb->ops->set_capi_mode() to
> switch switch CAPP to PCIe mode. In case set_capi_mode() indicates its
> OPAL_BUSY. It calls slot->ops.run_sm() to ensure that Opal slot reset
> state machine makes forward progress.
>
> Signed-off-by: Vaibhav Jain <vaibhav at linux.ibm.com>
> ---
> hw/phb4.c | 36 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/hw/phb4.c b/hw/phb4.c
> index 4284c467..615cda66 100644
> --- a/hw/phb4.c
> +++ b/hw/phb4.c
> @@ -2747,6 +2747,36 @@ static void phb4_training_trace(struct phb4 *p)
> }
> }
>
> +/*
> + * Trigger a creset to disable CAPI mode on kernel shutdown.
> + *
> + * This helper is called repeatedly by the host sync notifier mechanism, which
> + * relies on the kernel to regularly poll the OPAL_SYNC_HOST_REBOOT call as it
> + * shuts down.
> + */
> +static bool phb4_host_sync_reset(void *data)
> +{
> + struct phb4 *p = (struct phb4 *)data;
> + struct phb *phb = &p->phb;
> + struct pci_slot *slot = p->phb.slot;
> + int64_t rc = 0;
> +
> + /* Make sure no-one modifies the phb flags while we are active */
> + phb_lock(phb);
> +
> + /* Call phb ops to disable capi */
> + rc = phb->ops->set_capi_mode(phb, OPAL_PHB_CAPI_MODE_PCIE,
> + phb->ops->get_reserved_pe_number(phb));
> + if (rc == OPAL_BUSY) {
> + /* Run the phb reset state machine */
> + rc = slot->ops.run_sm(slot);
> + }
Nitpick, but since you're preparing a new version: at this point, the
comment looks weird, since there's no reason for a reset to occur, we
haven't changed the state of the slot yet. It's coming in a later patch,
by calling creset from set_capi_mode()
Fred
> +
> + phb_unlock(phb);
> +
> + return rc <= OPAL_SUCCESS;
> +}
> +
> static int64_t phb4_poll_link(struct pci_slot *slot)
> {
> struct phb4 *p = phb_to_phb4(slot->phb);
> @@ -4381,9 +4411,13 @@ static int64_t phb4_set_capi_mode(struct phb *phb, uint64_t mode,
> (CAPP_MAX_STQ_ENGINES |
> CAPP_MIN_DMA_READ_ENGINES)));
>
> - if (ret == OPAL_SUCCESS)
> + if (ret == OPAL_SUCCESS) {
> + /* register notification on system shutdown */
> + opal_add_host_sync_notifier(&phb4_host_sync_reset, p);
> +
> /* Disable fast reboot for CAPP */
> disable_fast_reboot("CAPP being enabled");
> + }
> else
> /* In case of an error mark the PHB detached */
> chip->capp_phb4_attached_mask ^= 1 << p->index;
>
More information about the Skiboot
mailing list