From: "Pali Rohár" <pali@kernel.org>
To: Gregory CLEMENT <gregory.clement@bootlin.com>,
Andrew Lunn <andrew@lunn.ch>
Cc: "Marek Behún" <kabel@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v4 mvebu 3/4] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng
Date: Thu, 20 May 2021 13:35:19 +0200 [thread overview]
Message-ID: <20210520113520.32240-4-pali@kernel.org> (raw)
In-Reply-To: <20210520113520.32240-1-pali@kernel.org>
When Marvell's rWTM firmware, which does not support the GET_RANDOM
command, is used, kernel prints an error message
hwrng: no data available
every 10 seconds.
Fail probing of this driver if the rWTM firmware does not support the
GET_RANDOM command.
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
---
drivers/firmware/turris-mox-rwtm.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index d7e3489e4bf2..3ef9687dddca 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -260,6 +260,27 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
return 0;
}
+static int check_get_random_support(struct mox_rwtm *rwtm)
+{
+ struct armada_37xx_rwtm_tx_msg msg;
+ int ret;
+
+ msg.command = MBOX_CMD_GET_RANDOM;
+ msg.args[0] = 1;
+ msg.args[1] = rwtm->buf_phys;
+ msg.args[2] = 4;
+
+ ret = mbox_send_message(rwtm->mbox, &msg);
+ if (ret < 0)
+ return ret;
+
+ ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
+ if (ret < 0)
+ return ret;
+
+ return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
+}
+
static int mox_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
{
struct mox_rwtm *rwtm = (struct mox_rwtm *) rng->priv;
@@ -497,6 +518,13 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev)
if (ret < 0)
dev_warn(dev, "Cannot read board information: %i\n", ret);
+ ret = check_get_random_support(rwtm);
+ if (ret < 0) {
+ dev_notice(dev,
+ "Firmware does not support the GET_RANDOM command\n");
+ goto free_channel;
+ }
+
rwtm->hwrng.name = DRIVER_NAME "_hwrng";
rwtm->hwrng.read = mox_hwrng_read;
rwtm->hwrng.priv = (unsigned long) rwtm;
--
2.20.1
next prev parent reply other threads:[~2021-05-20 11:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210308153703.23097-1-kabel@kernel.org>
2021-04-29 8:36 ` [PATCH v2 mvebu + mvebu/dt64 1/6] firmware: turris-mox-rwtm: fix reply status decoding function Pali Rohár
2021-04-29 8:36 ` [PATCH v2 mvebu + mvebu/dt64 2/6] firmware: turris-mox-rwtm: report failures better Pali Rohár
2021-04-29 8:36 ` [PATCH v2 mvebu + mvebu/dt64 3/6] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Pali Rohár
2021-04-29 8:36 ` [PATCH v2 mvebu + mvebu/dt64 4/6] firmware: turris-mox-rwtm: show message about HWRNG registration Pali Rohár
2021-04-29 8:36 ` [PATCH v2 mvebu + mvebu/dt64 5/6] firmware: turris-mox-rwtm: add marvell,armada-3700-rwtm-firmware compatible string Pali Rohár
2021-04-29 8:36 ` [PATCH v2 mvebu + mvebu/dt64 6/6] arm64: dts: marvell: armada-37xx: move firmware node to generic dtsi file Pali Rohár
2021-05-03 12:22 ` [PATCH v2 mvebu + mvebu/dt64 1/6] firmware: turris-mox-rwtm: fix reply status decoding function Andrew Lunn
2021-05-05 16:04 ` Marek Behún
2021-05-05 16:20 ` Andrew Lunn
2021-05-11 21:46 ` Pali Rohár
2021-05-06 9:07 ` [PATCH v3 " Pali Rohár
2021-05-06 9:07 ` [PATCH v3 mvebu + mvebu/dt64 2/6] firmware: turris-mox-rwtm: report failures better Pali Rohár
2021-05-06 9:07 ` [PATCH v3 mvebu + mvebu/dt64 3/6] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Pali Rohár
2021-05-12 0:56 ` Andrew Lunn
2021-05-20 11:38 ` Pali Rohár
2021-05-06 9:08 ` [PATCH v3 mvebu + mvebu/dt64 4/6] firmware: turris-mox-rwtm: show message about HWRNG registration Pali Rohár
2021-05-06 9:08 ` [PATCH v3 mvebu + mvebu/dt64 5/6] firmware: turris-mox-rwtm: add marvell,armada-3700-rwtm-firmware compatible string Pali Rohár
2021-05-06 9:08 ` [PATCH v3 mvebu + mvebu/dt64 6/6] arm64: dts: marvell: armada-37xx: move firmware node to generic dtsi file Pali Rohár
2021-05-12 0:59 ` Andrew Lunn
2021-05-20 11:40 ` Pali Rohár
2021-05-12 0:49 ` [PATCH v3 mvebu + mvebu/dt64 1/6] firmware: turris-mox-rwtm: fix reply status decoding function Andrew Lunn
2021-05-20 11:35 ` [PATCH v4 mvebu 0/4] firmware: turris-mox-rwtm: fixups Pali Rohár
2021-05-20 11:35 ` [PATCH v4 mvebu 1/4] firmware: turris-mox-rwtm: fix reply status decoding function Pali Rohár
2021-05-20 11:35 ` [PATCH v4 mvebu 2/4] firmware: turris-mox-rwtm: report failures better Pali Rohár
2021-05-21 1:38 ` Andrew Lunn
2021-05-20 11:35 ` Pali Rohár [this message]
2021-05-21 1:39 ` [PATCH v4 mvebu 3/4] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Andrew Lunn
2021-05-20 11:35 ` [PATCH v4 mvebu 4/4] firmware: turris-mox-rwtm: show message about HWRNG registration Pali Rohár
2021-05-21 1:40 ` Andrew Lunn
2021-06-17 13:06 ` [PATCH v4 mvebu 0/4] firmware: turris-mox-rwtm: fixups Gregory CLEMENT
2021-07-07 18:14 ` Pali Rohár
2021-07-23 12:45 ` Gregory CLEMENT
2021-07-23 12:47 ` Pali Rohár
2021-05-20 11:38 ` [PATCH v4 mvebu + mvebu/dt64 0/2] firmware: turris-mox-rwtm: new compatible string Pali Rohár
2021-05-20 11:38 ` [PATCH v4 mvebu + mvebu/dt64 1/2] firmware: turris-mox-rwtm: add marvell,armada-3700-rwtm-firmware " Pali Rohár
2021-05-21 1:41 ` Andrew Lunn
2021-06-17 13:07 ` Gregory CLEMENT
2021-05-20 11:38 ` [PATCH v4 mvebu + mvebu/dt64 2/2] arm64: dts: marvell: armada-37xx: move firmware node to generic dtsi file Pali Rohár
2021-05-21 1:42 ` Andrew Lunn
2021-06-17 13:08 ` Gregory CLEMENT
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=20210520113520.32240-4-pali@kernel.org \
--to=pali@kernel.org \
--cc=andrew@lunn.ch \
--cc=gregory.clement@bootlin.com \
--cc=kabel@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).