From patchwork Thu Dec 29 18:22:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 37480 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2533999wrt; Thu, 29 Dec 2022 10:26:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXtFYtyLCboX0FYmN4wcj6qPq0SU02Bwii05ozs6xk5ly5qi1qiSOeZ0sgqZsgCoF7guJt75 X-Received: by 2002:a17:907:c386:b0:82b:423b:b61c with SMTP id tm6-20020a170907c38600b0082b423bb61cmr24809808ejc.9.1672338408432; Thu, 29 Dec 2022 10:26:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672338408; cv=none; d=google.com; s=arc-20160816; b=MGFMFxSuzWHaVc9YvIX2l4tsx8LGmnVpht37sLqcRy9NyutBy5wqNhxo7rD10w1NBi UlK/uwntzaMStKEjsTN1RbZf0dtzjHQIUCby2pA1tTeF5n2T73IIEKmaQMVeWgiTbg+f LJB6mc1tQlwnkzMBuUuA5KkLoQOE7Taz3xJFKjO2n82Yv1izwbdPuQTeE+T46o9W5cnV gG9i982na8qKIj+KDiWfCASbyX7HTN36BYmkZ/6TYAULlLk77JOBEtAZ4ivzm6CYtk5/ 14JHWgawq/CUqpcrhNj5gImFffn7Rn3SB4Oje5Cq7laueTGirBXU5QSF5dkyP6xuzJ/m bXdQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=X2jSBRgWs+M8M4WMI9Mzf5iWqJLO5JxjkajhPjGvpy4=; b=lO84UrtHWhFfTiy71PVCee2PdySfig14UXXP+WrSFIyHjT29AAqYbXxt2SFP6wmgHO q1jCyBJ6xKMs2I+sZmqCE9F3D/CUHoIxo68utUuqOj+RCS4SInWjEfQUHuFYKO5DoVlc j+D9ZkfggrX4I9knyD/cDrcAGwGcreS7dT7TVdnXcQQ+Bp8z1WMn1bTbOYFjI3J6gtkY bp5rsGMy8fGHr/BKNpiVsRSy0gVZpvFywVAG8ZPlKzd1ZeogMVjLFoH/VBl6qfSrxoLT 2kZ0bNdEyFFHVeJq7yv74Hk7cT1M9PlbsfzsxKpxyc/EKm0MK2Aqa9rwf/HMIj8EF4JA a2HQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a170906848700b007c4fadff8dasi14939595ejx.933.2022.12.29.10.26.24; Thu, 29 Dec 2022 10:26:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234065AbiL2SZD (ORCPT + 99 others); Thu, 29 Dec 2022 13:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233924AbiL2SYY (ORCPT ); Thu, 29 Dec 2022 13:24:24 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B545413E9A for ; Thu, 29 Dec 2022 10:24:23 -0800 (PST) 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 F07931655; Thu, 29 Dec 2022 10:25:04 -0800 (PST) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 823023F71A; Thu, 29 Dec 2022 10:24:21 -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, etienne.carriere@linaro.org, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, wleavitt@marvell.com, peter.hilber@opensynergy.com, nicola.mazzucato@arm.com, tarek.el-sherbiny@arm.com, quic_kshivnan@quicinc.com, cristian.marussi@arm.com Subject: [PATCH v6 15/17] firmware: arm_scmi: Call Raw mode hooks from the core stack Date: Thu, 29 Dec 2022 18:22:51 +0000 Message-Id: <20221229182253.948175-16-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229182253.948175-1-cristian.marussi@arm.com> References: <20221229182253.948175-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753573918719422203?= X-GMAIL-MSGID: =?utf-8?q?1753573918719422203?= Add a few call sites where, if SCMI Raw mode access had been enabled in Kconfig, the needed SCMI Raw initialization and hooks are called. Signed-off-by: Cristian Marussi --- v5 --> v6 - fix error path for RAW mode in scmi_probe - use new debugfs Raw rootdir v4 --> v5 - rework to use multiple SCMI instances v3 --> v4 - add call hooks to support polled transports v1 --> v2 - fixes need to use multiple cinfo if available --- drivers/firmware/arm_scmi/driver.c | 53 +++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 8c0db8639b80..2a4f6024e090 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -37,6 +37,8 @@ #include "common.h" #include "notify.h" +#include "raw_mode.h" + #define CREATE_TRACE_POINTS #include @@ -150,6 +152,7 @@ struct scmi_debug_info { * bus * @devreq_mtx: A mutex to serialize device creation for this SCMI instance * @dbg: A pointer to debugfs related data (if any) + * @raw: An opaque reference handle used by SCMI Raw mode. */ struct scmi_info { int id; @@ -175,6 +178,7 @@ struct scmi_info { /* Serialize device creation process for this instance */ struct mutex devreq_mtx; struct scmi_debug_info *dbg; + void *raw; }; #define handle_to_scmi_info(h) container_of(h, struct scmi_info, handle) @@ -890,6 +894,11 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo, xfer->hdr.protocol_id, xfer->hdr.seq, MSG_TYPE_NOTIFICATION); + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) { + xfer->hdr.seq = MSG_XTRACT_TOKEN(msg_hdr); + scmi_raw_message_report(info->raw, xfer, SCMI_RAW_NOTIF_QUEUE); + } + __scmi_xfer_put(minfo, xfer); scmi_clear_channel(info, cinfo); @@ -903,6 +912,9 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo, xfer = scmi_xfer_command_acquire(cinfo, msg_hdr); if (IS_ERR(xfer)) { + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) + scmi_raw_error_report(info->raw, cinfo, msg_hdr, priv); + if (MSG_XTRACT_TYPE(msg_hdr) == MSG_TYPE_DELAYED_RESP) scmi_clear_channel(info, cinfo); return; @@ -936,6 +948,16 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo, complete(&xfer->done); } + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) { + /* + * When in polling mode avoid to queue the Raw xfer on the IRQ + * RX path since it will be already queued at the end of the TX + * poll loop. + */ + if (!xfer->hdr.poll_completion) + scmi_raw_message_report(info->raw, xfer, SCMI_RAW_REPLY_QUEUE); + } + scmi_xfer_command_release(info, xfer); } @@ -1050,6 +1072,14 @@ static int scmi_wait_for_reply(struct device *dev, const struct scmi_desc *desc, "RESP" : "resp", xfer->hdr.seq, xfer->hdr.status, xfer->rx.buf, xfer->rx.len); + + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) { + struct scmi_info *info = + handle_to_scmi_info(cinfo->handle); + + scmi_raw_message_report(info->raw, xfer, + SCMI_RAW_REPLY_QUEUE); + } } } else { /* And we wait for the response. */ @@ -2666,9 +2696,25 @@ static int scmi_probe(struct platform_device *pdev) if (ret) goto clear_dev_req_notifier; - if (scmi_top_dentry) + if (scmi_top_dentry) { info->dbg = scmi_debugfs_common_setup(info); + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT) && info->dbg) { + info->raw = scmi_raw_mode_init(handle, + info->dbg->top_dentry, + info->id, info->desc, + info->tx_minfo.max_msg); + if (IS_ERR(info->raw)) { + dev_err(dev, "Failed to initialize SCMI RAW Mode !\n"); + + ret = PTR_ERR(info->raw); + goto clear_dev_req_notifier; + } + + return 0; + } + } + if (scmi_notification_init(handle)) dev_err(dev, "SCMI Notifications NOT available.\n"); @@ -2726,6 +2772,8 @@ static int scmi_probe(struct platform_device *pdev) return 0; notification_exit: + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) + scmi_raw_mode_cleanup(info->raw); scmi_notification_exit(&info->handle); clear_dev_req_notifier: blocking_notifier_chain_unregister(&scmi_requested_devices_nh, @@ -2745,6 +2793,9 @@ static int scmi_remove(struct platform_device *pdev) struct scmi_info *info = platform_get_drvdata(pdev); struct device_node *child; + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) + scmi_raw_mode_cleanup(info->raw); + mutex_lock(&scmi_list_mutex); if (info->users) dev_warn(&pdev->dev,