From nobody Tue Nov 26 04:32:35 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4E5A1C4616; Mon, 21 Oct 2024 17:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729530989; cv=none; b=pCIeG2PaD6VI2g9ugukyWEX16Y+FbzGFOO8bADdXh+PGO2fOoG5NOyLtvwdoutsQWr83EKouwaafev8CGd5BE12dacO9xGlUo3QsgLTiQzNQGkiYqQsehEmKx5idkRHe4dzJif4Nuid2FvYkDxLudORFWfI9ijINitYBj5rI/lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729530989; c=relaxed/simple; bh=iJbXrdp+0IQydEFkS22NWSiymUkTx2RconF3fw/A4P8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ni8Ot3kcWB89YStYQ/CobaW3BF6dUqWHmV/hy/zMerH7OYwYZNLA/4u50WOprS/zyIHLpEFRe0HPEGk2rwzTtkZbtRYbR+ut15ZC9flREJupnbmQ/hquse4AehgmRu9Zjx/0AYVPYKGhd4GiYdCoz9Ud12oGbxxyUylaEcG4xj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 E2F43DA7; Mon, 21 Oct 2024 10:16:55 -0700 (PDT) Received: from pluto.fritz.box (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A83E3F528; Mon, 21 Oct 2024 10:16:25 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com Subject: [PATCH] firmware: arm_scmi: Reject clear channel request on A2P Date: Mon, 21 Oct 2024 18:15:44 +0100 Message-ID: <20241021171544.2579551-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.46.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The clear channel transport operation is supposed to be called exclusively on the P2A channel from the agent, since it relinquishes the ownership of the channel to the platform, after this latter has initiated some sort of P2A communication. Make sure that, if it is ever called on a A2P, is logged and ignored. Signed-off-by: Cristian Marussi Reviewed-by: Florian Fainelli --- drivers/firmware/arm_scmi/common.h | 2 ++ drivers/firmware/arm_scmi/driver.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi= /common.h index f9a4514421ee..6c2032d4f767 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -163,6 +163,7 @@ void scmi_protocol_release(const struct scmi_handle *ha= ndle, u8 protocol_id); * used to initialize this channel * @dev: Reference to device in the SCMI hierarchy corresponding to this * channel + * @is_p2a: A flag to identify a channel as P2A (RX) * @rx_timeout_ms: The configured RX timeout in milliseconds. * @handle: Pointer to SCMI entity handle * @no_completion_irq: Flag to indicate that this channel has no completion @@ -174,6 +175,7 @@ void scmi_protocol_release(const struct scmi_handle *ha= ndle, u8 protocol_id); struct scmi_chan_info { int id; struct device *dev; + bool is_p2a; unsigned int rx_timeout_ms; struct scmi_handle *handle; bool no_completion_irq; diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi= /driver.c index a477b5ade38d..5bd4cc68a3e3 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1048,6 +1048,11 @@ static inline void scmi_xfer_command_release(struct = scmi_info *info, static inline void scmi_clear_channel(struct scmi_info *info, struct scmi_chan_info *cinfo) { + if (!cinfo->is_p2a) { + dev_warn(cinfo->dev, "Invalid clear on A2P channel !\n"); + return; + } + if (info->desc->ops->clear_channel) info->desc->ops->clear_channel(cinfo); } @@ -2638,6 +2643,7 @@ static int scmi_chan_setup(struct scmi_info *info, st= ruct device_node *of_node, if (!cinfo) return -ENOMEM; =20 + cinfo->is_p2a =3D !tx; cinfo->rx_timeout_ms =3D info->desc->max_rx_timeout_ms; =20 /* Create a unique name for this transport device */ --=20 2.46.1