Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3866698pxv; Mon, 19 Jul 2021 10:38:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfVUvlv/HA7ll/K5oEL7t4Gfjy0yDVALcfIWxXoX8BIsVtHllUYuV2XzlW4a001BY5EPto X-Received: by 2002:a17:906:72d9:: with SMTP id m25mr29088383ejl.58.1626716287978; Mon, 19 Jul 2021 10:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626716287; cv=none; d=google.com; s=arc-20160816; b=ZHPQdZCqO/XTZqbL/zQ16Btrc2POkClxteJCQMQPr4Vn8g8s26j2JT2wjj0w+7ieCk GNDI+9blCULH8/dgwl281fCw/kSoIht8WrlxvvEPdnYKGD6r/Lm+HLeSRkibvqJxXDgI Zl/KWhboQHPGwAjEwGHLjVAnJEHQ1GminD9oqt+yuVj+C9j9zrJiHYmddnCxIqjppZy/ h20n0PhVc8wl/Ltkke4PqX+JHLvURKZgkNZwtvMB9aOtnhevG5U3BZwHN0RCkBoayrFB prZBYMBfTq/L4+3HZ/qf+Dzfurxakb/43g/dKzN+BBwsOSk8WGRkABOc+eAegLC5a6qi 1pvA== 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=MFAtLntTE7NtYn7Pi++Eb4Rt+GsZDjNqP0OokzhFxoQ=; b=06sdcDFERbTP1ovUBbhsvS4jcXQcVe9NwWjKKM/N3etfZie+aY+4/Q0IuU6Ak9Lp/J qUXV/KYYPe9UiqbA5Wi/l922kL8CzjjSikOlcVePaMZyxQafA/c5LxzeSNkS7eWpZqv6 aZK2zr9XGZ4NNzjAHXht91KoOkX9uB7PHyRT6bdFZh9751fmIxbI2B4OULdbGEVB7CMU 63tPzxclVS7txmz/AkNUG8iWXA9D5S0TkmVvQ7i5/+5zsy/5rcCQ3TkdTlhvMQgjBQJk FYRQVrba4ujjTywdbuHKlVAVdcGRk8BRK7jfkbYDtRZJ3EZYvx1CB0EvVE/NXA1OHplL kzyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EL5mIF4U; 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 u20si16128136ejz.711.2021.07.19.10.37.45; Mon, 19 Jul 2021 10:38:07 -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=EL5mIF4U; 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 S1357369AbhGSQvh (ORCPT + 99 others); Mon, 19 Jul 2021 12:51:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:38166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348001AbhGSPYR (ORCPT ); Mon, 19 Jul 2021 11:24:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 359E9613E7; Mon, 19 Jul 2021 16:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710426; bh=yYpygZPIxpVH2TcmcNWlBa5D/UMWPo6vn70XF0/MG1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EL5mIF4UdTWkzxLAIMn5N/CD0jDsTI5AgwI5YNEwbjBIW4RIJfAuogbTs5GD+9/v2 1Q1QUyhp8Mw5UkURmRVPY9q1oUIMNfT06KrMAA4xIQmWKmgGp3YPnYHEiLJShbmco5 8cYKBhDVVWp/HnZhbtBXsVE06h+ju1G4TqIL84ZY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Sasha Levin Subject: [PATCH 5.10 210/243] firmware: arm_scmi: Reset Rx buffer to max size during async commands Date: Mon, 19 Jul 2021 16:53:59 +0200 Message-Id: <20210719144947.707705497@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: Cristian Marussi [ Upstream commit 0cb7af474e0dbb2f500c67aa62b6db9fafa74de2 ] During an async commands execution the Rx buffer length is at first set to max_msg_sz when the synchronous part of the command is first sent. However once the synchronous part completes the transport layer waits for the delayed response which will be processed using the same xfer descriptor initially allocated. Since synchronous response received at the end of the xfer will shrink the Rx buffer length to the effective payload response length, it needs to be reset again. Raise the Rx buffer length again to max_msg_sz before fetching the delayed response to ensure full response is read correctly from the shared memory. Link: https://lore.kernel.org/r/20210601102421.26581-2-cristian.marussi@arm.com Fixes: 58ecdf03dbb9 ("firmware: arm_scmi: Add support for asynchronous commands and delayed response") Signed-off-by: Cristian Marussi [sudeep.holla: moved reset to scmi_handle_response as it could race with do_xfer_with_response] Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 6b2ce3f28f7b..f9901fadb3a4 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -268,6 +268,10 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo, return; } + /* rx.len could be shrunk in the sync do_xfer, so reset to maxsz */ + if (msg_type == MSG_TYPE_DELAYED_RESP) + xfer->rx.len = info->desc->max_msg_size; + scmi_dump_header_dbg(dev, &xfer->hdr); info->desc->ops->fetch_response(cinfo, xfer); -- 2.30.2