From nobody Mon Nov 25 11:32:54 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FE9D1D9339; Mon, 28 Oct 2024 12:02:11 +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=1730116933; cv=none; b=GRdX1X4bPLzubrtYQNBHF/pLnbK3lCjr3WWWVcRiemVmmYteLlfxI8X6S6wrEVUZXv2lyzxb5IYLv9WImemfEsm3apQgDjW2p2TmkbS1Zoe2ecMUhGe+tOLJxc39i46LrIazoqx4b4aqpPVWj05CzEnQ60qsDY1dsriAzVBuxhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730116933; c=relaxed/simple; bh=c12CM/G/A6JbS4n+TPvW3jO/rEsVh8BJOOGhyAH2iKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DKMBYMiAk3VgTgvnMIEGBbrd61WMyEGNKOWgVO9TIPdm58O04G+YQJHseOCKayZhBPBt06wJKWuWrozg7B3q3XMUKrhVLRQ+OhrKnMQx312guFIFtWVDV3LMQuu5tZpBSoFWN0A58dyO8MdAURqDxQ/t6xQSWFxk89gwlXNtlOc= 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 BB79B1691; Mon, 28 Oct 2024 05:02:40 -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 190AB3F73B; Mon, 28 Oct 2024 05:02:08 -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, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, etienne.carriere@st.com, peng.fan@oss.nxp.com, michal.simek@amd.com, quic_sibis@quicinc.com, quic_nkela@quicinc.com, dan.carpenter@linaro.org, Cristian Marussi , Florian Fainelli Subject: [PATCH v3 2/7] firmware: arm_scmi: Calculate virtio PDU max size dynamically Date: Mon, 28 Oct 2024 12:01:46 +0000 Message-ID: <20241028120151.1301177-3-cristian.marussi@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028120151.1301177-1-cristian.marussi@arm.com> References: <20241028120151.1301177-1-cristian.marussi@arm.com> 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" SCMI virtio transport maximum PDU size is currently hardcoded at build time; this will not play well with the possibile retrieval of a different size at run-time. Make the virtio transport derive the maximum PDU size from the max_msg_size provided by the SCMI core. No functional change. Reviewed-by: Florian Fainelli Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/transports/virtio.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_scmi/transports/virtio.c b/drivers/firmwa= re/arm_scmi/transports/virtio.c index d349766bc0b2..41aea33776a9 100644 --- a/drivers/firmware/arm_scmi/transports/virtio.c +++ b/drivers/firmware/arm_scmi/transports/virtio.c @@ -32,8 +32,8 @@ =20 #define VIRTIO_MAX_RX_TIMEOUT_MS 60000 #define VIRTIO_SCMI_MAX_MSG_SIZE 128 /* Value may be increased. */ -#define VIRTIO_SCMI_MAX_PDU_SIZE \ - (VIRTIO_SCMI_MAX_MSG_SIZE + SCMI_MSG_MAX_PROT_OVERHEAD) +#define VIRTIO_SCMI_MAX_PDU_SIZE(ci) \ + ((ci)->max_msg_size + SCMI_MSG_MAX_PROT_OVERHEAD) #define DESCRIPTORS_PER_TX_MSG 2 =20 /** @@ -90,6 +90,7 @@ enum poll_states { * @input: SDU used for (delayed) responses and notifications * @list: List which scmi_vio_msg may be part of * @rx_len: Input SDU size in bytes, once input has been received + * @max_len: Maximumm allowed SDU size in bytes * @poll_idx: Last used index registered for polling purposes if this mess= age * transaction reply was configured for polling. * @poll_status: Polling state for this message. @@ -102,6 +103,7 @@ struct scmi_vio_msg { struct scmi_msg_payld *input; struct list_head list; unsigned int rx_len; + unsigned int max_len; unsigned int poll_idx; enum poll_states poll_status; /* Lock to protect access to poll_status */ @@ -234,7 +236,7 @@ static int scmi_vio_feed_vq_rx(struct scmi_vio_channel = *vioch, unsigned long flags; struct device *dev =3D &vioch->vqueue->vdev->dev; =20 - sg_init_one(&sg_in, msg->input, VIRTIO_SCMI_MAX_PDU_SIZE); + sg_init_one(&sg_in, msg->input, msg->max_len); =20 spin_lock_irqsave(&vioch->lock, flags); =20 @@ -439,9 +441,9 @@ static int virtio_chan_setup(struct scmi_chan_info *cin= fo, struct device *dev, if (!msg) return -ENOMEM; =20 + msg->max_len =3D VIRTIO_SCMI_MAX_PDU_SIZE(cinfo); if (tx) { - msg->request =3D devm_kzalloc(dev, - VIRTIO_SCMI_MAX_PDU_SIZE, + msg->request =3D devm_kzalloc(dev, msg->max_len, GFP_KERNEL); if (!msg->request) return -ENOMEM; @@ -449,8 +451,7 @@ static int virtio_chan_setup(struct scmi_chan_info *cin= fo, struct device *dev, refcount_set(&msg->users, 1); } =20 - msg->input =3D devm_kzalloc(dev, VIRTIO_SCMI_MAX_PDU_SIZE, - GFP_KERNEL); + msg->input =3D devm_kzalloc(dev, msg->max_len, GFP_KERNEL); if (!msg->input) return -ENOMEM; =20 --=20 2.47.0