From patchwork Thu May 20 11:35:19 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: 12269747 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.4 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,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 68604C433B4 for ; Thu, 20 May 2021 11:38:35 +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 EC03D60FEE for ; Thu, 20 May 2021 11:38:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC03D60FEE 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=YvDz13EzEJqIcPr1Odmb9QzblXV5tcGG0kCyJXU7Stc=; b=pwWiMgCnZvbHcbXv2Zq/7l+Lfe smmeNJeMr0AXKMXoucFO6bf0P7Dld7kJKqyi1rsmpkNRCC2DY+TR4yHybkOvpXOERNBbq2qc5wBtF b8FqXJQdTBCkAztJpLObizI0Iu0ead0BZ9dO1fxVb6JlQk4AB9EXH3anjGvvkQixSY41QfG1sOUcW imTm4QqJr6xLAetn5EC+1sQ6mbReNiYUfo4oDYYZkGCu7KfHFyiuww5zssjgh2pexhHLCPFmF1Ime 35GG1fYvZwqbsp4JOajDpWKb2P9+lexSw3N1Re5slrNrtddcZy7wkbmzXYg0bUXo5/USmWo5Vmw8C JXlIjhHQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgz0-000W9u-7V; Thu, 20 May 2021 11:36:54 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgxk-000Vkl-KS for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 11:35:38 +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=b/nGroB4s9qQ4EMNmjpgAigIU2MgoI72rPx98xVa0HY=; b=AHF1Hf4O1jVJOfV1tsQnJwFYNN JrtwAEPcTYC0sl31VpkREwLQ2Huw4+jDGGO/oW/V/yCYuI8zzflkmb8YGxNv9+EA5kyMUj2u1grCs t1YTPvFCYGuo1L/VL49jOPVuaXcn/MbyO8el0Tn7vgw3+HB4w5LJB8H9aKN4S6EEEc0Ty4XsZEqoA YXy/N1T+MJArgqrBTSMpKbeKfbD+6C2/Di2sJH47clLHNf8S0SHDh+brTdMDioYwAHVef0r1CWfiT ++yU227ykRAeCdnRC0fns2EbEvLB160bC9sC+dlGCUnr/inyHevZqMNxuFgl5L7Hg/+xWnqBPb1L5 zU59BVXA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljgxh-00GFuy-8j for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:35:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1F3861358; Thu, 20 May 2021 11:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621510533; bh=0xNLSYCl73+5TMdOcS37E3N3QjdxqB/4vABPgh30trU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8+vnwFKcu8A3o70Wy21ipeJY2buUiNqdfH9UMmIhelxA5Mj8rnYXUGEmXUA3zJFv rhquoXbB9KRNHhwxAes8II/QjSNCXip1mypxA4Wm8Bn1PgevjUc8/5yCouUwxeHCbU EkNBBHS9jAT+uJ1XJ49z7KLLsr0Fj/LtnER2jF0BcHBXNrOh/f6VuTw17ze5AjPlet EPKZQm5+2oy5zhm5kJCGT9HZYkd9cOFTSZWbLyBNCPw7X58rZZrvzK0kDadjw/qgUY UxtcdyL0ZFF8bGILbi0Hp1N+i8e2ziBxCMG27x1jXkqwdFZwa67SUixLAwlMHwNErS LWV/KUihoadGA== Received: by pali.im (Postfix) id 9415D9D1; Thu, 20 May 2021 13:35:32 +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 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 Message-Id: <20210520113520.32240-4-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520113520.32240-1-pali@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> <20210520113520.32240-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_043533_347643_40ECD91C X-CRM114-Status: GOOD ( 13.38 ) 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. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Reviewed-by: Andrew Lunn --- 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;