Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3854404pxv; Mon, 19 Jul 2021 10:19:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8mS3FVVKMDPbvpZHTe63a/SCyYe0pvGN1iaqkx5cLRn9OzAGrOVtWWyxjBilZgwUphV+c X-Received: by 2002:aa7:db54:: with SMTP id n20mr35735098edt.21.1626715141522; Mon, 19 Jul 2021 10:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626715141; cv=none; d=google.com; s=arc-20160816; b=OJKT7AOsZz1L06np7RjVAPOeBpunPeaq3CtIUiygaYP2qu2LCWdUK1MgbiyF2Aw3ED nvy7X/sShESQ/XG7fmUfjPkGRWeHli2n8Jfw+j8JUnECub2hLF6m5mwQwN1jthhTAGrr PoIG8fAQ0gqOBtwtq/3pRrifNyVgcEMkVTtt6pRdbo70CRF0Ff9NFPmBB61CciBDfFa+ ZYZaPCiR0A/BozJ+EtqnwC9suMHSuKOWMu/h32/jZhGzbrf02UCASilU/sOAmCzoJ63X Q+XC7CPxdU+5hTIZSYCab27RbfhF+Q88rXRncVo3IJBs1lvR5k/Y/Lk8hfQIWsCkd8Xd yw0w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3+IO3N4FneP11iREPeG1nwWHHEHMMxG77z5R3LylvLo=; b=dK+EVlBSWDS79ad8A0IsZOTEM9ztexKQ8525cD4ftfMSslZCN4n83jNRrEU0nqiTZw VTgxT2e9mhlgmg0pJ3cWjcPa5pzEJMt8EVHWYTgIchL+/DQcSKUEcXAG20VyUesF+U1R fl382LAaH+ts1hXiHkC7LujjlRU4HfxmeWSFJlINsVtzfdKuAtpXbtEtEFZR8Q69v1mR qTtuYVitaP5l72817yWnvKCc1dw/HSHMw8KGyepjwAmdQFW3VnbR0px+KBu+r4D1dej2 jCt2+F5kzXpFAV6YELQMqPKjWjnf9UM8B0vjnUqT+uUsSEgbq50avmMfTSKS9zIwRu33 kcEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rb7F397S; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si16501733edx.50.2021.07.19.10.18.38; Mon, 19 Jul 2021 10:19:01 -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=@linuxfoundation.org header.s=korg header.b=rb7F397S; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355384AbhGSQgQ (ORCPT + 99 others); Mon, 19 Jul 2021 12:36:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:40694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348066AbhGSPYd (ORCPT ); Mon, 19 Jul 2021 11:24:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 870AF613F9; Mon, 19 Jul 2021 16:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710471; bh=dFc4zi4FSS9M1NxGHealxsT356amzx9zD8JG1iSt1lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rb7F397SSYZi4WAwxIZ8CYKMt+KP0lCvUl/uZCnsFys7ReckCEf3pitDxgMebdUr2 saUzKH+Y4Nz/Roan/lUFjH7HCYqTrqSJd2pI0xC73Bm7aIK8bMoONeqFkTxUBCTzuI JIRuvUcBU66T/o0Q0u0Gb+vb+h6atnaK3nQtU6H4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Andrew Lunn , Gregory CLEMENT , Sasha Levin Subject: [PATCH 5.10 231/243] firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng Date: Mon, 19 Jul 2021 16:54:20 +0200 Message-Id: <20210719144948.376223234@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Pali Rohár [ Upstream commit 2eab59cf0d2036a5a9e264f719b71c21ccf679c2 ] 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. Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Andrew Lunn Signed-off-by: Gregory CLEMENT Signed-off-by: Sasha Levin --- 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; -- 2.30.2