From patchwork Thu May 6 09:07:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12241891 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.7 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 CD727C433ED for ; Thu, 6 May 2021 09:12:12 +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 3946561041 for ; Thu, 6 May 2021 09:12:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3946561041 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=HiUL0s3NFVMgkXKINyLc7BxOgRW7xtuluoVj0Sm2yFY=; b=fiQFmBnM8kI6lL7Rv1/MBLsou 9ABP0JS46DUWSwQsWviFDmgKh+Husrhe47YBIqpifvSFmUyI0X2C94wz0EI8iPZwDoozbJ45IyBJg SomtX9hOZhcvPJkouYjNUiNtysLyLGtGWPCYn6fpALlgydSO4ZVHDdiqZ0HYRmAVgesWYyTDx+12m JOP4pzGnIzhyNr+SqNCOEnGzzjsPizolNhs8bIyk7XZLggMq/gOXH5On3t0lBrI/LfIykpqtTZolH yp7V5AK1nQxeYUq8UUr130r3ZT1azW4ypuixIa++2gPpcg1zPHdhffGf+eP4ij8mh1BSgrbWaKp8C IsLmVB4AQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lea0e-003kwB-Ov; Thu, 06 May 2021 09:09:28 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leZzk-003koZ-5L for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 09:08:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=FLlvs6ovGZfb8w0iuNcZbBcfcNUF7mpFvitEWswOGNY=; b=PCfGhjYGsRY/kfM3lJwsxXNMgG eP7uplcRumLjT4tQuOTh4E39v3fj8yluBDP42Hk6BxjkTwbs3aKOuAMsUr8ifTuY+Kdmx0iugwp7r FAN40/R+uJpNPMnoYcekhyFBkb9Z5CMBvM8L/vlfcVOYNZ1h8tf2HVMWOKPrGQafHdhvc6Zzql7DE LgVTrnnal8+jbUmV0AMczhivovGkH0/AIRThyj0cIbD0QkaxIFl/abgztAriU5Lnw6GAcaj3Vat3W tg+LiQG9t3hPYwZvHa3WB09IuCIoKkSaLTIS6vGmDMewmVNXGRBIxgl/WfjSp7smjH0DnwoL3apx1 uQI/K6Ig==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leZzh-005tRH-JF for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 09:08:30 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A36F613B5; Thu, 6 May 2021 09:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620292109; bh=2qAnuZ0glq7AD0WdQxX0rOeTrE+qvGfHUxQ2lCXNL8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=InnKih16wgbo7uvL8fVAgljGJ7Fuq274vMkcZmlj5XQ2kIIFHn0o4IMz6Zi2Y0vY7 PbbX+4+6Mv5ayp+Rr1zMeopl/R588ZwD9VX0Pm0toZj+21PA72keO0kAhCmZ6T58vK S4CG69a/e8WiwITj6Gc34DN5RtDUMFhHOhO5EtAaVm6bqmhFBok73DKr1iyhX39BYH IT4aT249gdHfyR+ZTO2sXoz1JfV262R9fZ6Ulwii0O7uTCC+QUn+VF10pZujRvqQC+ Tf+/n876A7NyixeAnshMoIDIBqWc3BKHyvUTQz1jN2w+r5aP31Zfnvd8enKSGGTkBz R3LKi4fFoR2Hg== Received: by pali.im (Postfix) id 16F96865; Thu, 6 May 2021 11:08:27 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Gregory CLEMENT , Andrew Lunn Cc: =?utf-8?q?Marek_Beh=C3=BAn?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 mvebu + mvebu/dt64 3/6] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Date: Thu, 6 May 2021 11:07:59 +0200 Message-Id: <20210506090802.14268-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210506090802.14268-1-pali@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> <20210506090802.14268-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_020829_695475_F276A8D3 X-CRM114-Status: GOOD ( 14.64 ) 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 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 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;