From patchwork Thu May 20 11:35:17 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: 12269749 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 4B8F8C433ED for ; Thu, 20 May 2021 11:39:11 +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 C5F7B6101D for ; Thu, 20 May 2021 11:39:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5F7B6101D 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=jepVzk2IhtqAdmAtU3ANjx/a6FrVeIH04krYwx1Dtcc=; b=jdr0h2uP9Cq/oSbtCf/fSTubYz hkCtIfC04Y2Ci77m+N77Bz/21+kbZmGbmFWFpCNfYXdVhIhm707/N/eVhy37qCv5CX9kCXH2F0/ha yuA4PljnoHmJzKCzT2BZSXDRfNzkpelFMi9/VtpGDzcBsEVLGx7bsWBsJv6svTIKeKbeldYuylv0S mCwBa1y3R0V0dtR8Jeqp4lBzojIrrT4oCKunvkxwLek7b8IAu1Py/LKUQvFM2SgIwthfJA+9ujLKl CAD9ovonoW21qFdzxrCynqPGQjZHxYhulGeMmzWwqPaD0PXJpvUIyIQZNJ0nv3G1o7GG1k5qfUKSI gGMoB0TQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgyQ-000Vxn-KR; Thu, 20 May 2021 11:36:18 +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-000Vki-9S 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=B601oesid6iXgjgdZKcDVkgX/QErjrE1s13BpnPil3E=; b=zgrxXMLFCeMFcI7jHqLibAYUhe lhl8zKMJYOw2nl3bv+gB9AaT5caERdx8UAlNZajdCsYjEbZbGc4ziSF0otPASkV6dISguJfwL4IX+ fvTrU63QkTPlRdhx1WkVfS0LeSbUCnHtxkpEVdl+Z0/xqGtsfLaLZVMLk6Bwv1s4xfF5PJKHZv4zz P+7t/cXdy+//Y2LzFsIsumHglUQjOK2/LtJ43QPFLlYnkVmo/ygjfktnlKoYQSaU5eIJOGgUreAbA ePT9gQbFspW0rgg8bqiRJaQ93Ip9kKHApVWHyEkKeAAFzhpj/UU8qBBbLya1aMwJ+lWTTTmEiF514 sWrIUH1Q==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljgxh-00GFun-1d for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:35:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A6A6611AB; 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=1621510532; bh=X3jopxsX61QS+or7ehscRsDEihXrE0LQ/xHPv2/OfAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kI1SIb7omMxdoGjWjB4B5Kty8kDjP2oWTMDvEjcj+fOeUHuES5d1b8flMxJoMPkQu ELh2Afz1ugedNnCe9UqQIQvpoYfDYXCseC7ujLiPh5gqOszMwwzF3uYuKbgQ4hUYT6 7AX3h9AYLvi4lHV3IhCNFzHguwgnekTGSaFhUc27FQXIjSxW3XvsZaOjxY13rAZxvr lQdWsgavCwvSvhT3W3ZGZ0qErfdCBAhrLnJRWGRYr886+nB+opva/9kgANkquoK9fp rh5ToZbt72QyDNcdh5vlTCl4ai19UY+QXw73CEI8wDVyOPgoGpHZYfzpyRPkZ3mg8o csBa5GMpSaGbA== Received: by pali.im (Postfix) id 787CC9D7; Thu, 20 May 2021 13:35:30 +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 1/4] firmware: turris-mox-rwtm: fix reply status decoding function Date: Thu, 20 May 2021 13:35:17 +0200 Message-Id: <20210520113520.32240-2-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_131561_90F155EE X-CRM114-Status: GOOD ( 11.75 ) 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 From: Marek Behún The status decoding function mox_get_status() currently contains an incorrect check: if the error status is not MBOX_STS_SUCCESS, it always returns -EIO, so the comparison to MBOX_STS_FAIL is never executed and we don't get the actual error code sent by the firmware. Fix this. Signed-off-by: Marek Behún Reviewed-by: Pali Rohár Reviewed-by: Andrew Lunn Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") --- drivers/firmware/turris-mox-rwtm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 62f0d1a5dd32..f85acdb3130c 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -147,11 +147,14 @@ MOX_ATTR_RO(pubkey, "%s\n", pubkey); static int mox_get_status(enum mbox_cmd cmd, u32 retval) { - if (MBOX_STS_CMD(retval) != cmd || - MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS) + if (MBOX_STS_CMD(retval) != cmd) return -EIO; else if (MBOX_STS_ERROR(retval) == MBOX_STS_FAIL) return -(int)MBOX_STS_VALUE(retval); + else if (MBOX_STS_ERROR(retval) == MBOX_STS_BADCMD) + return -ENOSYS; + else if (MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS) + return -EIO; else return MBOX_STS_VALUE(retval); } From patchwork Thu May 20 11:35:18 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: 12269745 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 0E8EEC433B4 for ; Thu, 20 May 2021 11:37:36 +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 8FCE360FEE for ; Thu, 20 May 2021 11:37:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FCE360FEE 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=/O5CZQaFnb/+h3zRKCSowpb1x3zahR6XOMizAgW2JfA=; b=EQVKK9nQ+6bjqE1/sKRjiKWLTD qzNF+s2gbd+9A8/Ph75w9+ufkm6rDkahq9KpLhdV2mXrEgJ/aswz+dB4dnt3bgn5Ub2EQvx3UuMwk lAYgChna9GqHO0VgMat4iGQtXG/gDTh/38OTvzNwfL0ctHndOl8DZZjiJc3QahunHmD8W29Mc2hMe WHTN0avQQZMhFS+Sd3oj9fv3N0lbgFfYmF7Ur4eeQpcSisX64mKoPrGM9gLafDxhwdAAzsXtDpWbH wvW/WWMCvaOjozr/+TjZgOY6jee+/p7O/ezVo8XkcJnpBqsgCs9v5EZqu8y9D90Dn6kVuso1v1woX QzSyrpHg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgxs-000VoA-KV; Thu, 20 May 2021 11:35:44 +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-000Vko-P0 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=x1q0Yij+PokrqPfZdGZIcHAmnwAyy0jlg9i0w0xoTJw=; b=O9bNJzv/7rLIx1SiHVEBzAVN23 WiQJ5wwUXdMOK0thqnV1u08j5CrthSWvuxyG7ug0B3iG7eTKjcHg6nd6hfTfu7OxGAa4h/A10IXj6 ccwViXhuJLxnPow58Mrh8jd1e0pPIEINc4cO1Ic+X7OhXVDMSVknwnHoZQmdSFTizNW2fm7W5IBxN ahy27Et3Afeki1XS98B/yPXs4IWJUYVe6x/FY6ISW81G1v2MML53upaiwlo8Z9DJKiticOKFQ6egg MCVm5v00p2AxRal5Oeuw2rd9jZFcBaYmSkbZUrNy/e3woFWCPQSMiPvWtirbz0JoF1PkXbxnhXnym 35vFLZRw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljgxh-00GFvS-U2 for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:35:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D29E6135A; Thu, 20 May 2021 11:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621510533; bh=24Nsl8oN56bAduw/YicAP/q9D+8TJgKDdu5gQxqytLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q4NN7oJFQNSbTFjFIJZRH0n2Umj69/HQJnIO4rJKrFojYNwYJq06LEzjUrr6CWmSd 2V+y+bUPJs293YpQCY/FNVPfECTrhSe0eF7V+VOJJgRSxtoxzQEsZsLhdMnIz0e6pE c60Tb6Hj3zGmYVcVYRnEJKxPKDC4rdmHYF7Shsn7IbvGVHRrzyL2WVAxFpvCaKZH6k j/Y6SS2mkmqygfkx0L5Nn1T7Y+PVTTXU+W4n/Greas/IzrjeX/fWK0MpsM+QfwYVH/ adW3BGzZtZtm6+uZaZoWWLbVUeXVAuQE0PLa7kPnHXfSf9MaV7WL9mtY7wb20rWaKA P/228fWS34oYg== Received: by pali.im (Postfix) id 8C52F9E7; Thu, 20 May 2021 13:35:31 +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 2/4] firmware: turris-mox-rwtm: report failures better Date: Thu, 20 May 2021 13:35:18 +0200 Message-Id: <20210520113520.32240-3-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_043534_008270_66C993F3 X-CRM114-Status: GOOD ( 14.19 ) 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 From: Marek Behún Report a notice level message if a command is not supported by the rWTM firmware. This should not be an error, merely a notice, because the firmware can be used on boards that do not have manufacturing information burned. Signed-off-by: Marek Behún Reviewed-by: Pali Rohár Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Reviewed-by: Andrew Lunn --- drivers/firmware/turris-mox-rwtm.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index f85acdb3130c..d7e3489e4bf2 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -204,11 +204,14 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return ret; ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval); - if (ret < 0 && ret != -ENODATA) { - return ret; - } else if (ret == -ENODATA) { + if (ret == -ENODATA) { dev_warn(rwtm->dev, "Board does not have manufacturing information burned!\n"); + } else if (ret == -ENOSYS) { + dev_notice(rwtm->dev, + "Firmware does not support the BOARD_INFO command\n"); + } else if (ret < 0) { + return ret; } else { rwtm->serial_number = reply->status[1]; rwtm->serial_number <<= 32; @@ -237,10 +240,13 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return ret; ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval); - if (ret < 0 && ret != -ENODATA) { - return ret; - } else if (ret == -ENODATA) { + if (ret == -ENODATA) { dev_warn(rwtm->dev, "Board has no public key burned!\n"); + } else if (ret == -ENOSYS) { + dev_notice(rwtm->dev, + "Firmware does not support the ECDSA_PUB_KEY command\n"); + } else if (ret < 0) { + return ret; } else { u32 *s = reply->status; 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; From patchwork Thu May 20 11:35:20 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: 12269751 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 691A4C43461 for ; Thu, 20 May 2021 11:39: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 2B8F361090 for ; Thu, 20 May 2021 11:39:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B8F361090 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=QUq2MzDeDQXJt73c+eDPu1rNSOy9/yXfg/LrzWYrRYY=; b=bKFE1T4XuDO+lbz5YqsxzNxDwI Puctm0m99BJEqMnTEwj/MYWfWwArnIh7RjkC6AzKWFO8EmXIjvQmsJsOVyhacl0E0GSPb/I7Xci9K wiX07YD6aM1rSWWmutIc21uzc2SHogep/74DSUEmxI7cHMcaoJqUu+o8qxaUcdad7rcWM3i+c5H7l NPn73sm7eHvyKv7pkbFeuJ6biSU9FjKh10twitHbEZFqvZV21MyXD39AL+xdhYzXaVfCChtUPC8ye ZxaVyhNAJgVHZjZZppw5u8f2zNuuelL6qhT8btRkuG0TpLhvHZQ6ZZABxOX319MFZp+VSvWY69PK9 jX8X3W4w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgzh-000WRL-2V; Thu, 20 May 2021 11:37:38 +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-000Vkn-OX 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=8NZnA7V+z/EHW9keu1iVSVZG84qryZ9Vb6MgLmI5Xdk=; b=KCcfg3EnemNaghLesY0HuAcMMR ws2LdFiotE+3HOjU7DMrD5YcXK8PSnjCBdR/ZtZxvvtRoHzfp9/1W1hbN/oZYVHEwffkvd0rOHsfO MSwNXFIVRonvs7/BcBTXsd6XoU9jVuFRuOBYXbd7cJRcq92fMo8lE8nzR/qXGsXkcKlof4uUlt4R+ SlfBB0tP8OzGDAGAOPoW5PAw3C1TvgR/hDiaHvv7ndKvlnEhTKccH85MR+rhvSfCaZ+fHLGvwfgte bE2xwHqv734CfKaw7U78vDDQCLlpDCxGSFFD00KeUJIQ75nqrkp42bagmm6g9w6w8LSMZ6jK3j3u8 dELiiZoQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljgxi-00GFvg-Cm for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:35:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id EBB236139A; Thu, 20 May 2021 11:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621510534; bh=+OylOm4Xj8hBbMUtVil2h9pLATRR6MkYlmUTGrTyvwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dd2G9td5G8U2vepQ8ECKHyqFX2sgaknt7JBZMpDznOWe2eHaYjRaUssw9mQBdcwOJ o1UyU/ws56UB0xma4x5fRaSAoVDPxVG00Ld0atahY+rNsdz0XcHpo45sEm1+o+cefj dnoBGEoBQKkHwEYtHxVeLFoWVDj0EzEx//xUn4EYhc588GJ30X/XPi5FmThhk0l7C7 I+nbPW+OjNjn+kcz586nO9D4VW1YgsWQ4sfDj/dJ3l6oeUHX4HV9OdYbAqhd9xNe77 BhXtjIy/nvojQPjQ9QYrNi3D5ymuCnjPI1xbWWKKUM7egx328CU3i2YeGrMCNKywJS w7MeVDJhjuhdA== Received: by pali.im (Postfix) id ADE929D1; Thu, 20 May 2021 13:35:33 +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 4/4] firmware: turris-mox-rwtm: show message about HWRNG registration Date: Thu, 20 May 2021 13:35:20 +0200 Message-Id: <20210520113520.32240-5-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_043534_477107_BEEFB192 X-CRM114-Status: GOOD ( 10.18 ) 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 Currently it is hard to determinate if on Armada 3720 device is HWRNG by running kernel accessible or not. So print information message into dmesg when HWRNG is available and registration was successful. Signed-off-by: Pali Rohár Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Reviewed-by: Andrew Lunn --- drivers/firmware/turris-mox-rwtm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 3ef9687dddca..1cf4f1087492 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -542,6 +542,8 @@ static int turris_mox_rwtm_probe(struct platform_device *pdev) goto free_channel; } + dev_info(dev, "HWRNG successfully registered\n"); + return 0; free_channel: