From patchwork Mon Aug 12 17:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 13760879 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 03D2BC3DA7F for ; Mon, 12 Aug 2024 17:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=sIapS1uyplAofy1rLAKaznoV4CFlsBAbokuVXhjxl2Q=; b=B1JuHqfHOaaFQjTJQnlCgoTwO5 1NQPrUzTni5dHtwjfWqSjpP9tfOjYkFhXOxk92iIRpZtTOEihWiADDv+wfvrD/HLWefFHj6tBUmKH v0+u4Vq7XtHxc0h+3Iy9MeK2HeJ84TtCLRFj+AItBpfMRFNQ4+UvPiC6eKKa8bt2H007xrhihqeYx ADV4shDt8yo4wr2NgJNJv0YQgQGGojJQcgXua9iLIZicCXnLSdole3j92A9OXBqNsayyUtaCfKfxo 9VIjJ5IOysP6rvfIOXpNJPBGyCcr5T8QNe1nE4y0g+l40bJGqstORx2pRsGmI9Y7DRL8HimQB7uy7 IFXXGmSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdYwU-000000012c8-41el; Mon, 12 Aug 2024 17:34:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdYvs-000000012PY-0Ucl for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 17:34:13 +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 EF92AFEC; Mon, 12 Aug 2024 10:34:36 -0700 (PDT) Received: from pluto.guestnet.cambridge.arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 69FFB3F40C; Mon, 12 Aug 2024 10:34: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, ptosi@google.com, dan.carpenter@linaro.org, souvik.chakravarty@arm.com, Cristian Marussi Subject: [PATCH v4 0/9] Make SCMI transport as standalone drivers Date: Mon, 12 Aug 2024 18:33:31 +0100 Message-ID: <20240812173340.3912830-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_103412_262313_0546947E X-CRM114-Status: GOOD ( 20.46 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, Till now the SCMI transport layer was being built embedded into in the core SCMI stack. Some of these transports, despite being currently part of the main SCMI module, are indeed also registered with different subsystems like optee or virtio, and actively probed also by those: this led to a few awkward and convoluted tricks to properly handle such interactions at boot time in the SCMI stack. Moreover some partner expressed the desire to be able to fully modularize the transports components. This series aim to make all such transports as standalone drivers that can be optionally loaded as modules. In order to do this, at first some new mechanism is introduced to support this new capability while maintaining, in parallel, the old legacy embedded transports; then each transport, one by one, is transitioned to be a standalone driver and finally the old legacy support for embedded transport is removed. Patch [1/9] is a fix around the chan_free method for OPTEE transport; it is really unrelated to this series, but included to avoid conflicts. Patch [2/9] is a mostly unrelated (but much needed) clean-up from Peng, which I included in this series to avoid conflicts at merge. Patch [3/9] simply collects the existing datagram manipulation helpers in a pair of function pointers structures, in preparation for later reworks. Patch [4/9] adds the bulk of the new logic to the core SCMI stack and then each existing transport is transitioned to be a standalone driver in patches 5,6,7,8 while shuffling around the compatibles. (no DT change is needed of curse for backward compatibility) While doing this I kept the module authorship in line with the main author(S) as spitted out by git-blame. Finally patch [9/9] removes all the legacy dead code from the core SCMI stack. No new symbol EXPORT has been added. The new transport drivers have been tested, as built-in and LKM, as follows: - mailbox on JUNO - virtio on emulation - optee on QEMU/optee using Linaro setup Exercised using the regular SCMI drivers stack and the SCMI ACS suite, testing commands, replies, delayed responses and notification. Multiple virtual SCMI instances support has been tested too. SMC has NOT been tested/exercised at run-time, only compile-tested. (due to lack of hardware) Note that in this new setup, all the probe deferral and retries between the SCMI core stack and the transports has been removed, since no more needed. Moreover the new drivers have been tested also with a fully modularized SCMI stack, i.e.: scmi-core.ko + scmi-module.ko + scmi_transport_*.ko [ + vendor modules ] Note that V4 is based on sudeep/for-next/scmi/updates [1] on top of commit: 4d5921a39f67 ("dt-bindings: firmware: arm,scmi: Add support for system power protocol") Any feedback, and especially testing (:D) is welcome. Thanks, Cristian [1]: https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git/log/?h=for-next/scmi/updates --- v3 --> v4 - dropped useless MODALIAS - moved transport drivers to their own subdir transports/, within their own submenu v2 --> v3 - rebased on v6.11-rc1 - fixed spacing in Kconfig - fixed Copyrights all over - fixed platform_driver_register callsite in OPTEE transport - refactored DEFINE_SCMI_TRANSPORT_DRIVER() to: + use alloc + add_data + add platform drivers methods so as to implictly use a standard default device_release method. + drop .remove method in favour of devres_add_action_or_reset + use explicit parameter passing (no more concatenation) - renamed scmi_transport_lookup() to scmi_transport_setup() - use IOMEM_ERR_PTR to avoid sparse issues v1 --> v2 - fixed setup_shmem_iomap to address also SMC needs (QC/nikunj) (silencing also warnings by kernel test robot ) - using __free OF cleanup.h magic in setup_shmme_iomap - properly handle platform_driver_register() failures (Dan) - fixed a few commit message style - added a few missing static in scmi_desc (addresses warnings by kernel test robot ) Cristian Marussi (8): firmware: arm_scmi: Fix double free in OPTEE transport firmware: arm_scmi: Introduce packet handling helpers firmware: arm_scmi: Add support for standalone transport drivers firmware: arm_scmi: Make MBOX transport a standalone driver firmware: arm_scmi: Make SMC transport a standalone driver firmware: arm_scmi: Make OPTEE transport a standalone driver firmware: arm_scmi: Make VirtIO transport a standalone driver firmware: arm_scmi: Remove legacy transport-layer code Peng Fan (1): firmware: arm_scmi: Introduce setup_shmem_iomap drivers/firmware/arm_scmi/Kconfig | 111 +---------- drivers/firmware/arm_scmi/Makefile | 6 +- drivers/firmware/arm_scmi/common.h | 184 +++++++++++++----- drivers/firmware/arm_scmi/driver.c | 142 +++++--------- drivers/firmware/arm_scmi/msg.c | 32 ++- drivers/firmware/arm_scmi/shmem.c | 85 ++++++-- drivers/firmware/arm_scmi/transports/Kconfig | 123 ++++++++++++ drivers/firmware/arm_scmi/transports/Makefile | 9 + .../arm_scmi/{ => transports}/mailbox.c | 73 ++++--- .../arm_scmi/{ => transports}/optee.c | 131 ++++++------- .../firmware/arm_scmi/{ => transports}/smc.c | 58 +++--- .../arm_scmi/{ => transports}/virtio.c | 103 +++++----- 12 files changed, 593 insertions(+), 464 deletions(-) create mode 100644 drivers/firmware/arm_scmi/transports/Kconfig create mode 100644 drivers/firmware/arm_scmi/transports/Makefile rename drivers/firmware/arm_scmi/{ => transports}/mailbox.c (86%) rename drivers/firmware/arm_scmi/{ => transports}/optee.c (89%) rename drivers/firmware/arm_scmi/{ => transports}/smc.c (87%) rename drivers/firmware/arm_scmi/{ => transports}/virtio.c (94%)