From patchwork Thu Nov 3 19:52:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 15139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp737422wru; Thu, 3 Nov 2022 12:55:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GJnmrCE9qDpKEEZ1NUvPeRcmayNOEMlkzH7LfooMQb1ydTA1xDktKWl2N6WHGvlSHrarn X-Received: by 2002:a17:906:3b17:b0:7ad:b645:9e3e with SMTP id g23-20020a1709063b1700b007adb6459e3emr27649974ejf.140.1667505342779; Thu, 03 Nov 2022 12:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667505342; cv=none; d=google.com; s=arc-20160816; b=GUPSuvLYVlwgBOcRjO5bxIf2W5Js7CgS3+8rNmFKNbjt4rKED0QkTFr7wzEW2iZZJr 4DrENO7IhIS3o1gRgROimas5H4GpAsTkLVblCZTHcOmZQDV6OI8InDuqXeJSb0a4eSrk XpoUV/cslNdppD0o5sxYaXmVWJoTLQQICbQjFanmMMGq88Tyh6e8K1UeJjbwpzCrWOpv 6+uqbdyHgMOsbGR90ouHLuOqxkvL79jdU2eJnVNbed/LNXCBJarLJliHI4oXqXyEdmDA VEHu7fj2yBMBnV+BML9qQnTpHaor4QgtqhmDmB0ht0UppirufrKr2z2uZqoG5ur+e4mK Gpew== 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=V6yu8K50ZHwKKefwItjO6igjCJ3O+3+Lu1ekv8lvR9k=; b=Zj6blIWWuhDTd3ba5kL6dUj/S6iLH8dfkGJ6UunBnZTmaqCRmsAmheVKSotN+mU2xa iXvRP84mF8wbUQfHAJJEXfKPcuv4RWC3lu5E3kN40LRx+o4l4lw7qIuXV0MJkCk8jp+M RueCt+H/XsdRLm3ihJ7F07haElVLJVGAHxpYFpMO4e8nlnK7eqDCJxjLddw+3P1IMNK8 nNzN/HagfwYMN1Wgy+oas3TJzABhOz63uGON4O8ADB1ZKclhdj60OOztR8KFN5W/QLBl oIftXifqH1zR7G9ti3NNOQQH85MZfN6w6zArP+bO+RU8DfykxgQk98Y0/MB5cZJw9rTS o52Q== 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 sg13-20020a170907a40d00b007adb2862222si2442575ejc.828.2022.11.03.12.55.08; Thu, 03 Nov 2022 12:55:42 -0700 (PDT) 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 S231346AbiKCTyN (ORCPT + 99 others); Thu, 3 Nov 2022 15:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbiKCTxU (ORCPT ); Thu, 3 Nov 2022 15:53:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 810E120194 for ; Thu, 3 Nov 2022 12:53:19 -0700 (PDT) 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 865E31FB; Thu, 3 Nov 2022 12:53:25 -0700 (PDT) Received: from e120937-lin.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 447733F534; Thu, 3 Nov 2022 12:53:17 -0700 (PDT) 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 v5 13/14] firmware: arm_scmi: Call Raw mode hooks from the core stack Date: Thu, 3 Nov 2022 19:52:24 +0000 Message-Id: <20221103195225.1028864-14-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221103195225.1028864-1-cristian.marussi@arm.com> References: <20221103195225.1028864-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?1748506082012601140?= X-GMAIL-MSGID: =?utf-8?q?1748506082012601140?= 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 --- 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 | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index bbb43b65cbfd..9f8e5d42c7aa 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 @@ -136,6 +138,7 @@ struct scmi_protocol_instance { * @notify_priv: Pointer to private data structure specific to notifications. * @node: List head * @users: Number of users of this instance + * @raw: An opaque reference handle used by SCMI Raw mode. */ struct scmi_info { struct device *dev; @@ -155,6 +158,7 @@ struct scmi_info { void *notify_priv; struct list_head node; int users; + void *raw; }; static struct dentry *scmi_raw_top_dentry; @@ -772,6 +776,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); @@ -785,6 +794,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; @@ -817,6 +829,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); } @@ -927,6 +949,14 @@ static int scmi_wait_for_reply(struct device *dev, const struct scmi_desc *desc, !xfer->is_raw ? "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. */ @@ -2613,6 +2643,18 @@ static int scmi_probe(struct platform_device *pdev) if (ret) goto clear_txrx_setup; + if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT)) { + info->raw = scmi_raw_mode_init(handle, scmi_raw_top_dentry, + info->desc, + info->tx_minfo.max_msg); + if (IS_ERR(info->raw)) { + dev_err(dev, "Failed to initialize SCMI RAW Mode !\n"); + return PTR_ERR(info->raw); + } + + return 0; + } + if (scmi_notification_init(handle)) dev_err(dev, "SCMI Notifications NOT available.\n"); @@ -2687,6 +2729,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,