Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1198098pxy; Thu, 29 Apr 2021 01:38:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyccw+a49H1TwP7tTy37SJTGZ43s6m0p2+hywnKg1MezBM9eCzmeBhKoN1CsMr+ns9DruD/ X-Received: by 2002:a17:906:49c1:: with SMTP id w1mr34573323ejv.178.1619685509248; Thu, 29 Apr 2021 01:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619685509; cv=none; d=google.com; s=arc-20160816; b=k8AR0fcfcXioCYMbju6TIIs2ckcVQ0LhBMDUwYDM7Dt8mebimvy9SFdWQfTvUYZdZA bB7MT0lY0mhJN7WX7+ABwLJgow4BcaNvM6SWDueeUX98+7hKvaZendpAn+kWPx1T0KWA hF71m7IzrtHi083fczfTI36o9EJiy0qUlmLmMFYydb+YJ3Mb02WmYK+5pMqScex9//ww W6QmwBu8hkiXP46qgjU2jT4WzJ6uDN9ZTaHonLvmasQ4FHlut2OXpa6N+Ct9dILUFUgZ rtYJ4OPngJGRujUKMHFIhEoYt+GOkR0mKK3nB4T1AaD4G/swbMAfOK8XXRJrIhRHbeYE eoZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FLlvs6ovGZfb8w0iuNcZbBcfcNUF7mpFvitEWswOGNY=; b=DLLROJEM0rDmHBEuWwgOcfOqGaiox7bDuzWIkOQ542qfO64R4fDj7ity94gvq4h8GU TIz58uKZomjeCRbyKHB7h5DzovY1jZkdZ8pLaE+bjeBQ7IuUUFjD8KboHiNHVT5lDpR0 ROuxR5shPgpfb95gGEheu1ayuMIrVARyJTUQzGbizhZKopE7F8e+IzCn6dltOWGD+BOz Pdn6BaVcRjUIOA1npAXUAhhihHbq6p3rfIdZec/lXkqODhR4umrlG0l8UagnzdbKGMq6 z+GhDDfRAGpq7iL0O/5SJ3MBOs1wwtwj1zicHkk5J3ALrZNy4H1rauYJeZ697ceQFVBY HDyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N5z99kBz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si2215977edy.531.2021.04.29.01.38.06; Thu, 29 Apr 2021 01:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N5z99kBz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239947AbhD2Ihl (ORCPT + 99 others); Thu, 29 Apr 2021 04:37:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239916AbhD2Ihi (ORCPT ); Thu, 29 Apr 2021 04:37:38 -0400 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=20Roh=C3=A1r?= To: Gregory CLEMENT , Andrew Lunn Cc: =?UTF-8?q?Marek=20Beh=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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. 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; -- 2.20.1