From patchwork Wed Aug 4 11:35:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 492232 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 91925C4338F for ; Wed, 4 Aug 2021 11:36:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B07F60EB2 for ; Wed, 4 Aug 2021 11:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236698AbhHDLgT (ORCPT ); Wed, 4 Aug 2021 07:36:19 -0400 Received: from foss.arm.com ([217.140.110.172]:59650 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236502AbhHDLgT (ORCPT ); Wed, 4 Aug 2021 07:36:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 196A013D5; Wed, 4 Aug 2021 04:36:07 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E9D5E3F719; Wed, 4 Aug 2021 04:36:05 -0700 (PDT) From: Cristian Marussi To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, sashal@kernel.org, cristian.marussi@arm.com, Sudeep Holla Subject: [PATCH] firmware: arm_scmi: Add delayed response status check Date: Wed, 4 Aug 2021 12:35:55 +0100 Message-Id: <20210804113555.9021-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit f1748b1ee1fa0fd1a074504045b530b62f949188 ] A successfully received delayed response could anyway report a failure at the protocol layer in the message status field. Add a check also for this error condition. Cc: # v5.4+ Link: https://lore.kernel.org/r/20210608103056.3388-1-cristian.marussi@arm.com Fixes: 58ecdf03dbb9 ("firmware: arm_scmi: Add support for asynchronous commands and delayed response") Signed-off-by: Cristian Marussi Signed-off-by: Sudeep Holla --- Upstream commit f1748b1ee1fa0fd1a074504045b530b62f949188 has been already applied to stable/linux-5.13.y, this is a backport with conflicts resolved for v5.4 and v5.10 (The code fixed here was introduced after v4.19) --- drivers/firmware/arm_scmi/driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 48e6e2b48924..4e43bdfa041f 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -515,8 +515,12 @@ int scmi_do_xfer_with_response(const struct scmi_handle *handle, xfer->async_done = &async_response; ret = scmi_do_xfer(handle, xfer); - if (!ret && !wait_for_completion_timeout(xfer->async_done, timeout)) - ret = -ETIMEDOUT; + if (!ret) { + if (!wait_for_completion_timeout(xfer->async_done, timeout)) + ret = -ETIMEDOUT; + else if (xfer->hdr.status) + ret = scmi_to_linux_errno(xfer->hdr.status); + } xfer->async_done = NULL; return ret;