From patchwork Mon Nov 22 23:06:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12693387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E84CC433EF for ; Mon, 22 Nov 2021 23:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To:References: List-Owner; bh=OEj88Trx6xQt5QcNItqziNXmigkaT5bRS3zKsi14jAw=; b=dSwHWhMieSsLRr C4aMf/yimkWlXNlUujoo92Nrp1CnkNvhRwAp5hGjR+RW0SXy7EVyeIeni54kmNeoO66+URDft92Uu WHx2lbODz5C3qBMTAJaufQTO2cJ5ALGWmPEJcsuByzqEL30f1h97Wn8WxvOaOI2nOVUAv9cdqqpEb VJOyK+5kVgjlXqR6hNWX1ktW7aCoahtr8NnWAMBG3uv5OVJJaYZD8sq5KOf7t9TxbPOfDFoROMipy HExu5sJNIb2V7K45aKJuMXaGsL7aIVUfUTeIX0rgWitvAdEsrGzorSOy5DH6cRGNbOJbkXQ3aEcI+ vQR010OmwB4eGQtpcY+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpIWC-000LrK-O8; Mon, 22 Nov 2021 23:14:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpIOx-000JTh-Mh for linux-arm-kernel@lists.infradead.org; Mon, 22 Nov 2021 23:07:09 +0000 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 B0E12ED1; Mon, 22 Nov 2021 15:07:03 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 588773F5A1; Mon, 22 Nov 2021 15:07:02 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, cristian.marussi@arm.com Subject: [PATCH v6 00/16] Introduce atomic support for SCMI transports Date: Mon, 22 Nov 2021 23:06:24 +0000 Message-Id: <20211122230640.1345-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211122_150707_903890_7196826F X-CRM114-Status: GOOD ( 19.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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, This series mainly aims to introduce atomic support for SCMI transports that can support it. After a bit of refactoring in the first 5 patches of the series, in [06/16], as a closely related addition, it is introduced a common way for a transport to signal to the SCMI core that it does not offer completion interrupts, so that the usual polling behaviour will be required: this can be done enabling statically a global polling behaviour for the whole transport with flag scmi_desc.force_polling OR dynamically enabling at runtime such polling behaviour on a per-channel basis using the flag scmi_chan_info.no_completion_irq, typically during .chan_setup(). The usual per-command polling selection behaviour based on hdr.poll_completion is preserved as before. Patch [07/16], ports SMC transport to use the common core completions when completion interrupt is available or otherwise revert to use common core polling mechanism above introduced: this avoids the improper call of scmi_rx_callback directly in smc_send_message. With [08/16] I introduce a flag to allow a transport to signal to the core that upon return of a .send_message() the requested command execution can be assumed by the core to have been fully completed by the platform, so that the response payload (if any) can be immediately fetched without the need to poll the channel. In [09/16] and [10/16] I enable such flag for SMC amd OPTEE transports. With [11/16] a transport that supports atomic operations on its TX path can now declare itself as .atomic_enabled and, if the platform has been also configured to use such atomic operation mode via Kconfig, the SCMI core will refrain itself too from sleeping on the RX path and instead rely on polling on the correspondent when such atomic behaviour is requested from the upper layers. (like the Clock framework) Then in [12/16] SMC is converted to be .atomic_enabled by substituting the mutexes with busy-waiting to keep the channel 'locked' ONLY IF the SMC transport is configured to operate in atomic mode. (CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE=y) In [13/16] a new parameter is added to mark_txdone transport operation; this will be needed to support polling/atomic support in SCMI virtio. [14/16] adds polling and configurable atomic mode support to SCMI virtio. (CONFIG_ARM_SCMI_TRANSPORT_VIRTIO_ATOMIC_ENABLE=y) Finally [15/16] adds support for atomic clock enable/disable requests to the SCMI Clock protocol layer, while in [16/16] the SCMI Clock driver is modified to get optional support for atomic operations when operating on an atomically configured SCMI transport. Atomic support has been tested against the virtio transport in regards to the above mentioned Clock enable/disable operations. (echo 1 > /sys/kernel/debug/clk/myclock/clk_prepare_enable) Polling has been tested on mailbox transport. The series is based on sudeep/for-next/scmi [1] on top of: commit 530897ecdb3d ("firmware: arm_scmi: Make virtio Version_1 compliance optional") Any feedback welcome. Thanks, Cristian [1]: https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/log/?h=for-next/scmi --- V5 --> V6 - changed default polling timeout - refactored SCMI RX path - added timeout_ms to traces in RX-path - added OPTEE support for sync_cmds_atomic_replies - reworked the whole atomic support in SCMI core removing any reliance on IRQs. (using pure polling) - added new parameter to mark_txdone - added new SCMI VirtIO polling/atomic support - reviewed Clock SCMI Driver atomic support: now supporting both clk_prepare and clk_enable when atomic transport is detected - added CCs V4 --> V5 - removed RFCs tags - added scmi_desc.atomic_enabled flags and a few Kconfig options to set atomic mode for SMC and VirtIO transports. Default disabled. - added Kconfig option to enable forced polling as a whole on the Mailbox transport - removed .poll_done callback from SMC transport since no real polling is needed once sync_cmds_atomic_replies is set - made atomic_capable changes on SMC transport dependent on Kconfig CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE: so no change and no busy waiting if atomic mode is NOT enabled in Kconfig. - made const: force_polling/atomic_capable/atomic_enabled/sync_cmds_atomic_replies V3 --> V4 - rebased on linux-next/master next-20210824 - renamed .needs_polling to .no_completion_irq - added .sync_cmds_atomic_replies - make SMC use .sync_cmd_atomic_replies V2 --> v3 - rebased on SCMI VirtIO V6 which in turn is based on v5.14-rc1 Cristian Marussi (16): firmware: arm_scmi: Perform earlier cinfo lookup call in do_xfer firmware: arm_scmi: Set polling timeout to max_rx_timeout_ms firmware: arm_scmi: Refactor message response path include: trace: Add new scmi_xfer_response_wait event firmware: arm_scmi: Use new trace event scmi_xfer_response_wait firmware: arm_scmi: Add configurable polling mode for transports firmware: arm_scmi: Make smc transport use common completions firmware: arm_scmi: Add sync_cmds_atomic_replies transport flag firmware: arm_scmi: Make smc support atomic sync commands replies firmware: arm_scmi: Make optee support atomic sync commands replies firmware: arm_scmi: Add support for atomic transports firmware: arm_scmi: Add atomic mode support to smc transport firmware: arm_scmi: Add new parameter to mark_txdone firmware: arm_scmi: Add atomic mode support to virtio transport firmware: arm_scmi: Add atomic support to clock protocol clk: scmi: Support atomic clock enable/disable API drivers/clk/clk-scmi.c | 56 ++++++-- drivers/firmware/arm_scmi/Kconfig | 29 ++++ drivers/firmware/arm_scmi/clock.c | 22 ++- drivers/firmware/arm_scmi/common.h | 26 +++- drivers/firmware/arm_scmi/driver.c | 195 +++++++++++++++++++------ drivers/firmware/arm_scmi/mailbox.c | 3 +- drivers/firmware/arm_scmi/optee.c | 18 +-- drivers/firmware/arm_scmi/smc.c | 108 ++++++++++---- drivers/firmware/arm_scmi/virtio.c | 212 ++++++++++++++++++++++++++-- include/linux/scmi_protocol.h | 11 ++ include/trace/events/scmi.h | 28 ++++ 11 files changed, 606 insertions(+), 102 deletions(-)