The ZL3073x chips can perform a full device reset that reboots the firmware and reloads the whole configuration from flash. Expose it through the devlink 'fw_activate' reload action using the previously added zl3073x_dev_hw_reset() helper. reload_down() stops normal operation for both DRIVER_REINIT and FW_ACTIVATE. reload_up() additionally resets the device for FW_ACTIVATE before restarting normal operation. Normal operation is always restarted on a best-effort basis even if the reset fails, so the dpll device is not left unregistered, but the reset failure is still propagated as the overall reload_up() error so devlink reports a failed reload and does not claim FW_ACTIVATE was performed in actions_performed. The 'clock_id' devlink param update is only meaningful for DRIVER_REINIT, since the devlink core only loads a new driverinit param value ahead of that action; factor it into a helper and call it only from that case. reload_up() now also propagates the error from the restart step instead of always returning success, so devlink correctly reports a failed reload. A missing or corrupted configuration in flash is not treated as a failure. As during probe, only the devlink interface is kept so that a correct configuration can be flashed. Document the supported reload actions in the driver's devlink documentation. Also state there, as recommended by Microchip, that the output clocks may glitch during a flash update or a device reset. Reviewed-by: Min Li Tested-by: Min Li Signed-off-by: Ivan Vecera --- No changes since v1 --- Documentation/networking/devlink/zl3073x.rst | 25 +++++++ drivers/dpll/zl3073x/devlink.c | 77 ++++++++++++++------ 2 files changed, 81 insertions(+), 21 deletions(-) diff --git a/Documentation/networking/devlink/zl3073x.rst b/Documentation/networking/devlink/zl3073x.rst index fc5a8dc272a774..a653b9e1fa9d61 100644 --- a/Documentation/networking/devlink/zl3073x.rst +++ b/Documentation/networking/devlink/zl3073x.rst @@ -62,4 +62,29 @@ During the flash procedure, the standard firmware interface is not available, so the driver unregisters all DPLLs and associated pins, and re-registers them once the flash procedure is complete. +The output clocks may glitch during the flash procedure unless they are stopped +and disabled before the flash utility is loaded and the power-up configuration +stored in flash has them disabled. The driver does not stop or disable the +output clocks itself. + The driver does not support any overwrite mask flags. + +Reload +====== + +The ``zl3073x`` driver supports the following ``devlink-reload`` actions: + +``driver_reinit`` + Unregisters all DPLLs and associated pins and registers them again. A new + value of the ``clock_id`` parameter is applied by this action. + +``fw_activate`` + Resets the device, which reboots the firmware and reloads the whole + configuration from flash, and registers all DPLLs and associated pins again. + A new value of the ``clock_id`` parameter is not applied by this action. + The output clocks may glitch during the reset unless they are stopped and + disabled before the reset and the power-up configuration stored in flash has + them disabled. + +If the configuration stored in flash is wrong or missing, the DPLLs stay +unregistered and only the devlink interface remains available. diff --git a/drivers/dpll/zl3073x/devlink.c b/drivers/dpll/zl3073x/devlink.c index 10143ec81a1167..0ff93889acd503 100644 --- a/drivers/dpll/zl3073x/devlink.c +++ b/drivers/dpll/zl3073x/devlink.c @@ -89,29 +89,26 @@ zl3073x_devlink_reload_down(struct devlink *devlink, bool netns_change, { struct zl3073x_dev *zldev = devlink_priv(devlink); - if (action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT) - return -EOPNOTSUPP; + switch (action) { + case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: + case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: + /* Stop normal operation */ + zl3073x_dev_stop(zldev); - /* Stop normal operation */ - zl3073x_dev_stop(zldev); + return 0; - return 0; + default: + return -EOPNOTSUPP; + } } static int -zl3073x_devlink_reload_up(struct devlink *devlink, - enum devlink_reload_action action, - enum devlink_reload_limit limit, - u32 *actions_performed, - struct netlink_ext_ack *extack) +zl3073x_devlink_clock_id_update(struct zl3073x_dev *zldev) { - struct zl3073x_dev *zldev = devlink_priv(devlink); + struct devlink *devlink = priv_to_devlink(zldev); union devlink_param_value val; int rc; - if (action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT) - return -EOPNOTSUPP; - rc = devl_param_driverinit_value_get(devlink, DEVLINK_PARAM_GENERIC_ID_CLOCK_ID, &val); @@ -124,14 +121,51 @@ zl3073x_devlink_reload_up(struct devlink *devlink, zldev->clock_id = val.vu64; } - /* Restart normal operation */ - rc = zl3073x_dev_start(zldev); - if (rc) - dev_warn(zldev->dev, "Failed to re-start normal operation\n"); + return rc; +} - *actions_performed = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT); +static int +zl3073x_devlink_reload_up(struct devlink *devlink, + enum devlink_reload_action action, + enum devlink_reload_limit limit, + u32 *actions_performed, + struct netlink_ext_ack *extack) +{ + struct zl3073x_dev *zldev = devlink_priv(devlink); + int rc, restart_rc; + + *actions_performed = 0; + switch (action) { + case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: + rc = zl3073x_devlink_clock_id_update(zldev); + if (rc) + NL_SET_ERR_MSG_MOD(extack, "Failed to update clock_id"); + break; + case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: + /* Reset the device CPU to reboot the firmware and reload the + * configuration from flash. On failure, normal operation is + * still restarted below on a best-effort basis. + */ + rc = zl3073x_dev_hw_reset(zldev); + if (rc) { + NL_SET_ERR_MSG_MOD(extack, "Hardware reset failed"); + break; + } + *actions_performed |= BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE); + break; + default: + return -EOPNOTSUPP; + } - return 0; + /* Restart normal operation */ + restart_rc = zl3073x_dev_start(zldev); + if (restart_rc) + NL_SET_ERR_MSG_WEAK_MOD(extack, + "Failed to re-start normal operation"); + else + *actions_performed |= BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT); + + return rc ? : restart_rc; } void zl3073x_devlink_flash_notify(struct zl3073x_dev *zldev, const char *msg, @@ -270,7 +304,8 @@ zl3073x_devlink_flash_update(struct devlink *devlink, static const struct devlink_ops zl3073x_devlink_ops = { .info_get = zl3073x_devlink_info_get, - .reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT), + .reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) | + BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE), .reload_down = zl3073x_devlink_reload_down, .reload_up = zl3073x_devlink_reload_up, .flash_update = zl3073x_devlink_flash_update, -- 2.56.1