From patchwork Mon Mar 8 15:37:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12122775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E74FCC433E6 for ; Mon, 8 Mar 2021 15:39:16 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8AD216521D for ; Mon, 8 Mar 2021 15:39:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AD216521D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TvEDBVrv1BAg4qVauES6UCfh8N7iRXKBQKPYu//dV9w=; b=Bo8PUQFBJLrJbfeuhNNBEPIj1 5bKxVp1liMMPWO6dL07JHJUvNd+Hc5fqEIgFl8zYN/1eFtMylCz1zItwEBY+oh8YWuxCsi0fLPQr2 nM8ANSms0az7I4MUAVeOGveI1qcuzR1nGTZyJbqmSVk3mxnX4EiFnC+SB4jCHUjX3zx65KV5T3U6j ReQSjPpDEee3A7j5aPXiqG+rrw51eyQ9hOD32xbiBa21H9UVLIJ2x0uiLkAa3Sr+aNFhLQdRXv6Y/ cvtc+svfXCpliSRr8DLTVc1W4GhqzZJAPIcQ8hOFxQE/q7LLNbEapMh+FDxBkhEgT20arxfsqpPOG q9bxGWjrw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJHx4-000ev6-Vi; Mon, 08 Mar 2021 15:37:47 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJHws-000eot-FU for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 15:37:36 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F7B465227; Mon, 8 Mar 2021 15:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217853; bh=UvlwAXuTf/WSevmLoNHuimORXWgQj45bWzZau2BFOgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cae6qEZm+8a0oMdRbuWEC64bFMfIIHlmiV3AZp80R23VDI72HhNPHSOuL68m72O5u MTC5aucROijigr4aUZfMh9lBWtLhCU8khMnUlKNP6oIf+2eRlYNzUwumsx/Oqe/wxg ZVFBCiNnaTwMaWe3hT4xYHeQ/DWMBJnp0eYBoFsJHsNlmHFk/6uvqIFYWNa/7YTUze 116wBZkc/P1zwCyx+hctJVGiWRH3iV96Bp+ZG3p7v0+4N9siggO2oAN7K2f3nmwc8s 1u8Uwa5aD/dEg44tcqBZE6xOipAkjzjhunCbL8HZH2UvCWv0Utv8ZBvsu/TDpbUngh a0wmJjfy4o8nA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Gregory CLEMENT Cc: linux-arm-kernel@lists.infradead.org, pali@kernel.org, =?utf-8?q?Marek_B?= =?utf-8?q?eh=C3=BAn?= Subject: [PATCH mvebu + mvebu/dt64 3/4] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Date: Mon, 8 Mar 2021 16:37:02 +0100 Message-Id: <20210308153703.23097-3-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210308153703.23097-1-kabel@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_153735_314107_C82B4975 X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Pali Rohár 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. This makes it possible to put this driver's compatible into generic armada-37xx device tree, to be available for other Armada 3720 devices besides Turris MOX. If they use the rWTM firmware from CZ.NIC, they will have HWRNG available, and if not, the driver won't be complaining. Signed-off-by: Pali Rohár Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Signed-off-by: Marek Behún --- 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 0f9e40a28fb0..2b56dd05961f 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;