From patchwork Thu Apr 29 08:36:33 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: 12230787 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 E6AA4C433B4 for ; Thu, 29 Apr 2021 08:38:58 +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 4C0AC6135B for ; Thu, 29 Apr 2021 08:38:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C0AC6135B 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=NLEJl83mTtmxLh7cNWKW+7MX7 InIQ67ZgBf02QuXBZGFsjt8VGpB3MyzeTm0BPDO6GX/3YjdHZyg55k5zn8k0dNcJjfCxu9f9Z3weG ceI5pFNO6IU+txmZfwmBgfQe6T3/UpL7gnT0Ocr6QWapEoy3E58p6NRmtUgwduMiZEWzg0MeTHm/M ZX9s9sbeymjG9t9QYTySV0nWctzqosvDHUILnfNSjbJpa7YjotM63kTjwyiBZQQtpouQFWQ6lSBPV 8u96jtNSZgC4hsO+zhUVoKJZG3L/PN5O+whxbE3vlRxL5rmmPYg14vB3RpdjuBgp7PsE7Ehkmd6Ip q+Vh2sIKg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lc2Ak-005KEL-Dq; Thu, 29 Apr 2021 08:37:23 +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 1lc2AI-005KBT-Ik for linux-arm-kernel@desiato.infradead.org; Thu, 29 Apr 2021 08:36:54 +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=imp9nQNQojKI9zzNudaauEL1Zv v0v3+V6jdmvCvmSahujK258hpgCmj8JoDAv0DgMfoe2TKMofdhQbAZ0udtpXxMSRP2T7jbg5fAmnA F//fzD8SLmt603dmPTAFHnijs76b1li2M3recLimpANAZ9I27p1PJK3J7Eo8l4FDO+aXT/efuKn3h xOJ6G2oQP8rvjAIbDDqw4UlcdQJrXzWoZjh6iLma7yf0udxtL/ycKJlEjwm7CNA7vMuaVCUHs9+pt fo3Fr6BtpNl7QFIwfCpwMHgDKy0Cy6A5QhgwlRIaMFcm7Wz4vTacRGxm2V9zFfme6LRfaR2Ajc1z3 v5gj1CDQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lc2AG-000UZg-0o for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 08:36:53 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 67951613B4; Thu, 29 Apr 2021 08:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619685411; bh=2qAnuZ0glq7AD0WdQxX0rOeTrE+qvGfHUxQ2lCXNL8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5z99kBzrOrO5N3XTumPMUpPZExJtOdotoLhGXf3C20gqEqJ256d5oK7P5uXcGKLS ohvR7hBUHcGkALFvgWY90FCamd5G+EevWmbnVOQOzFi2DHn/mkA1bob8KDHb3epsnf DGckQ6/iwtqKn66b+ZxR0sAtjlGVEbdZpYVS5/4u+Y9iFDjz6wUTmZFa+KgkBZN4Rq CEdnXwToC2xePL1NRXbPWiKxPUeqji5RZ8sr2LjbkywAoBelXx5NbR5jkvqXrQVCYh ygjkli9u4EYqhKDm8w6qBdSNRlJr9fKLaz9M+OFgCvNzepXH0M3SZJoWKHzmRO/B2a VsT4BdsSq1NlQ== Received: by pali.im (Postfix) id 693FDA43; Thu, 29 Apr 2021 10:36:49 +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 v2 mvebu + mvebu/dt64 3/6] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Date: Thu, 29 Apr 2021 10:36:33 +0200 Message-Id: <20210429083636.22560-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210429083636.22560-1-pali@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> <20210429083636.22560-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210429_013652_117680_4391991B X-CRM114-Status: GOOD ( 14.51 ) 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;