public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Asmaa Mnebhi <asmaa@nvidia.com>
To: <markgross@kernel.org>, <vadimp@nvidia.com>,
	<hdegoede@redhat.com>, <linux-kernel@vger.kernel.org>
Cc: Asmaa Mnebhi <asmaa@nvidia.com>
Subject: [PATCH v2 2/2] mlxbf-bootctl: Support setting the ARM boot state to "OS up"
Date: Wed, 9 Aug 2023 12:28:57 -0400	[thread overview]
Message-ID: <20230809162857.21243-3-asmaa@nvidia.com> (raw)
In-Reply-To: <20230809162857.21243-1-asmaa@nvidia.com>

The BlueField has internal registers to store the ARM boot states.
Support setting the BlueField ARM boot state to "OS up".

Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
---
v1->v2:
- No changes made to this patch. It has already been approved.
  This is just to update [PATCH v2 1/2]

 drivers/platform/mellanox/mlxbf-bootctl.c | 25 +++++++++++++++++++++++
 drivers/platform/mellanox/mlxbf-bootctl.h |  5 +++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/platform/mellanox/mlxbf-bootctl.c b/drivers/platform/mellanox/mlxbf-bootctl.c
index 52d1272478a4..0bf29eee1e70 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.c
+++ b/drivers/platform/mellanox/mlxbf-bootctl.c
@@ -80,6 +80,7 @@ static const char * const mlxbf_rsh_log_level[] = {
 	"INFO", "WARN", "ERR", "ASSERT"};
 
 static DEFINE_MUTEX(icm_ops_lock);
+static DEFINE_MUTEX(os_up_lock);
 
 /* ARM SMC call which is atomic and no need for lock. */
 static int mlxbf_bootctl_smc(unsigned int smc_op, int smc_arg)
@@ -431,6 +432,28 @@ static ssize_t large_icm_store(struct device *dev,
 	return res.a0 ? -EPERM : count;
 }
 
+static ssize_t os_up_store(struct device *dev,
+			   struct device_attribute *attr,
+			   const char *buf, size_t count)
+{
+	struct arm_smccc_res res;
+	unsigned long val;
+	int err;
+
+	err = kstrtoul(buf, 10, &val);
+	if (err)
+		return err;
+
+	if (val != 1)
+		return -EINVAL;
+
+	mutex_lock(&os_up_lock);
+	arm_smccc_smc(MLNX_HANDLE_OS_UP, 0, 0, 0, 0, 0, 0, 0, &res);
+	mutex_unlock(&os_up_lock);
+
+	return count;
+}
+
 static DEVICE_ATTR_RW(post_reset_wdog);
 static DEVICE_ATTR_RW(reset_action);
 static DEVICE_ATTR_RW(second_reset_action);
@@ -439,6 +462,7 @@ static DEVICE_ATTR_RO(secure_boot_fuse_state);
 static DEVICE_ATTR_WO(fw_reset);
 static DEVICE_ATTR_WO(rsh_log);
 static DEVICE_ATTR_RW(large_icm);
+static DEVICE_ATTR_WO(os_up);
 
 static struct attribute *mlxbf_bootctl_attrs[] = {
 	&dev_attr_post_reset_wdog.attr,
@@ -449,6 +473,7 @@ static struct attribute *mlxbf_bootctl_attrs[] = {
 	&dev_attr_fw_reset.attr,
 	&dev_attr_rsh_log.attr,
 	&dev_attr_large_icm.attr,
+	&dev_attr_os_up.attr,
 	NULL
 };
 
diff --git a/drivers/platform/mellanox/mlxbf-bootctl.h b/drivers/platform/mellanox/mlxbf-bootctl.h
index fc5019c90fc5..613963d448f2 100644
--- a/drivers/platform/mellanox/mlxbf-bootctl.h
+++ b/drivers/platform/mellanox/mlxbf-bootctl.h
@@ -90,6 +90,11 @@
 
 #define MAX_ICM_BUFFER_SIZE 10
 
+/*
+ * SMC function ID to set the ARM boot state to up
+ */
+#define MLNX_HANDLE_OS_UP    0x82000014
+
 /* SMC function IDs for SiP Service queries */
 #define MLXBF_BOOTCTL_SIP_SVC_CALL_COUNT	0x8200ff00
 #define MLXBF_BOOTCTL_SIP_SVC_UID		0x8200ff01
-- 
2.30.1


  parent reply	other threads:[~2023-08-09 16:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 16:28 [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Asmaa Mnebhi
2023-08-09 16:28 ` [PATCH v2 1/2] mlxbf-bootctl: Support the large icmc write/read Asmaa Mnebhi
2023-08-09 16:40   ` Vadim Pasternak
2023-08-09 16:28 ` Asmaa Mnebhi [this message]
2023-08-09 20:16 ` [PATCH v2 0/2] mlxbf-bootctl: Support access to the large icm size and setting the BlueField boot state Hans de Goede
2023-08-09 20:17   ` Asmaa Mnebhi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230809162857.21243-3-asmaa@nvidia.com \
    --to=asmaa@nvidia.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=vadimp@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox