platform/mellanox: add firmware reset support
authorKhalil Blaiech <kblaiech@nvidia.com>
Wed, 5 Apr 2023 13:16:29 +0000 (09:16 -0400)
committerHans de Goede <hdegoede@redhat.com>
Thu, 6 Apr 2023 12:26:03 +0000 (14:26 +0200)
Add a new sysfs to initiate firmware reset in isolation mode.

Reviewed-by: David Thompson <davthompson@nvidia.com>
Signed-off-by: Khalil Blaiech <kblaiech@nvidia.com>
Link: https://lore.kernel.org/r/10da04fa43e8acce5d4ec173e225c28b9e979e4b.1675790783.git.kblaiech@nvidia.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/mellanox/mlxbf-bootctl.c
drivers/platform/mellanox/mlxbf-bootctl.h

index 1c7a288b59a5c52e072b72ae5e615388aa18d6be..5e41c270195c7da26e0e9598e4ae5f6a4f96c981 100644 (file)
@@ -244,11 +244,29 @@ static ssize_t secure_boot_fuse_state_show(struct device *dev,
        return buf_len;
 }
 
+static ssize_t fw_reset_store(struct device *dev,
+                             struct device_attribute *attr,
+                             const char *buf, size_t count)
+{
+       unsigned long key;
+       int err;
+
+       err = kstrtoul(buf, 16, &key);
+       if (err)
+               return err;
+
+       if (mlxbf_bootctl_smc(MLXBF_BOOTCTL_FW_RESET, key) < 0)
+               return -EINVAL;
+
+       return count;
+}
+
 static DEVICE_ATTR_RW(post_reset_wdog);
 static DEVICE_ATTR_RW(reset_action);
 static DEVICE_ATTR_RW(second_reset_action);
 static DEVICE_ATTR_RO(lifecycle_state);
 static DEVICE_ATTR_RO(secure_boot_fuse_state);
+static DEVICE_ATTR_WO(fw_reset);
 
 static struct attribute *mlxbf_bootctl_attrs[] = {
        &dev_attr_post_reset_wdog.attr,
@@ -256,6 +274,7 @@ static struct attribute *mlxbf_bootctl_attrs[] = {
        &dev_attr_second_reset_action.attr,
        &dev_attr_lifecycle_state.attr,
        &dev_attr_secure_boot_fuse_state.attr,
+       &dev_attr_fw_reset.attr,
        NULL
 };
 
index 148fdb43b4351da74155729d65a3a63626ac0010..b48243f60a59f55371db7405ddb6aca84b2a453e 100644 (file)
 
 #define MLXBF_BOOTCTL_GET_DIMM_INFO            0x82000008
 
+/*
+ * Initiate Firmware Reset via TYU. This might be invoked during the reset
+ * flow in isolation mode.
+ */
+#define MLXBF_BOOTCTL_FW_RESET  0x8200000D
+
 /* SMC function IDs for SiP Service queries */
 #define MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT       0x8200ff00
 #define MLXBF_BOOTCTL_SIP_SVC_UID              0x8200ff01