Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3507936pxb; Mon, 24 Jan 2022 11:01:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4v43wjcatAkLloee6fLipRTSv9KBtwZKmME7eyJb+o6M6FfDSyYIrsi9P5LWBuv8gxFv9 X-Received: by 2002:a05:6a00:181a:b0:4c1:3c75:9c54 with SMTP id y26-20020a056a00181a00b004c13c759c54mr15248988pfa.6.1643050913136; Mon, 24 Jan 2022 11:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050913; cv=none; d=google.com; s=arc-20160816; b=dZoM3bvU8nZA9qfhosFcBtWXiWt20zOT6czX5zcjbLuc9ZY9fypPHaoIOzpSomqR7w tSeMoU5X/6UIx7GkphwRoydp0v8vpzt0+8oSfvlEpQl95T2QsclG39LY4ilyaQRMVpnw 0r12r2PajR/6Cz8e4Cxbxa5yF2cZkYP9r/YFi6jfkSdSnkpS+u9cmV/BesCj7O+QVsso 5gzN7I3cuknJzq9pID8DLugoXBUKwiEmgQ0kp46VeI6yzM4MUmp8CswmWV5xEUo17pW6 0qrT7KOKf8h08KDoPQkEC6U8JWPYsBr652EMnBoX7cTGZLO+ssdChF9Jv8g7kEtb3vFE PD5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=WrWyRUQENa7aG8DkT05j5qwOgtB/KRRJ9QDlQc46KVQ=; b=0bTn7ar5SX3LH2KQftfr3KugF0Q3dznCZ9mcSweMwadtcUrVOXQiYM6V/1BWhpfvp9 wXrN7Lgra08BRqHfcHEI95z5I/Q68MO/mxnKxaTAdZ126h27tp1wB0Z46Lg8PFB4XmZb o/TV3pvo0Plgi3LyrV9bJ+2JZQJIM782weJolQywRig6XcP/ydbhhEp8boJRdplXog8E eOA3F4C10Z/9fhtxopg40YqiZemRGFWcbPMvYmRluSh7nFYNRYWFv4lURpz3/d2cCDxK hbWhL2o8JgLiGedqEMsGGTf/Tw32A0+ljftOnzvsOCE5mbfrDKaTb/owEaANA5K0LKlT WeHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mu4si156275pjb.68.2022.01.24.11.01.40; Mon, 24 Jan 2022 11:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237074AbiAXKEb (ORCPT + 99 others); Mon, 24 Jan 2022 05:04:31 -0500 Received: from foss.arm.com ([217.140.110.172]:56024 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235062AbiAXKEN (ORCPT ); Mon, 24 Jan 2022 05:04:13 -0500 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 64F9D6D; Mon, 24 Jan 2022 02:04:12 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 78A773F73B; Mon, 24 Jan 2022 02:04:10 -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, peter.hilber@opensynergy.com, igor.skalkin@opensynergy.com, cristian.marussi@arm.com Subject: [PATCH 3/6] firmware: arm_scmi: Support optional system wide atomic_threshold Date: Mon, 24 Jan 2022 10:03:38 +0000 Message-Id: <20220124100341.41191-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124100341.41191-1-cristian.marussi@arm.com> References: <20220124100341.41191-1-cristian.marussi@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An SCMI agent can be configured system-wide with a well-defined atomic threshold: only SCMI synchronous command whose latency has been advertised by the SCMI platform to be lower or equal to this configured threshold will be considered for atomic operations, when requested and supported by the underlying transport at all. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 27 ++++++++++++++++++++++++--- include/linux/scmi_protocol.h | 5 ++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index dc972a54e93e..d2ac6291b84b 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -131,6 +131,12 @@ struct scmi_protocol_instance { * MAX_PROTOCOLS_IMP elements allocated by the base protocol * @active_protocols: IDR storing device_nodes for protocols actually defined * in the DT and confirmed as implemented by fw. + * @atomic_threshold: Optional system wide DT-configured threshold, expressed + * in microseconds, for atomic operations. + * Only SCMI synchronous commands reported by the platform + * to have an execution latency lesser-equal to the threshold + * should be considered for atomic mode operation: such + * decision is finally left up to the SCMI drivers. * @notify_priv: Pointer to private data structure specific to notifications. * @node: List head * @users: Number of users of this instance @@ -149,6 +155,7 @@ struct scmi_info { struct mutex protocols_mtx; u8 *protocols_imp; struct idr active_protocols; + unsigned int atomic_threshold; void *notify_priv; struct list_head node; int users; @@ -1409,15 +1416,22 @@ static void scmi_devm_protocol_put(struct scmi_device *sdev, u8 protocol_id) * SCMI instance is configured as atomic. * * @handle: A reference to the SCMI platform instance. + * @atomic_threshold: An optional return value for the system wide currently + * configured threshold for atomic operations. * * Return: True if transport is configured as atomic */ -static bool scmi_is_transport_atomic(const struct scmi_handle *handle) +static bool scmi_is_transport_atomic(const struct scmi_handle *handle, + unsigned int *atomic_threshold) { + bool ret; struct scmi_info *info = handle_to_scmi_info(handle); - return info->desc->atomic_enabled && - is_transport_polling_capable(info); + ret = info->desc->atomic_enabled && is_transport_polling_capable(info); + if (ret && atomic_threshold) + *atomic_threshold = info->atomic_threshold; + + return ret; } static inline @@ -1957,6 +1971,13 @@ static int scmi_probe(struct platform_device *pdev) handle->version = &info->version; handle->devm_protocol_get = scmi_devm_protocol_get; handle->devm_protocol_put = scmi_devm_protocol_put; + + /* System wide atomic threshold for atomic ops .. if any */ + if (!of_property_read_u32(np, "atomic_threshold", + &info->atomic_threshold)) + dev_info(dev, + "SCMI System wide atomic threshold set to %d us\n", + info->atomic_threshold); handle->is_transport_atomic = scmi_is_transport_atomic; if (desc->ops->link_supplier) { diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 9f895cb81818..fdf6bd83cc59 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -619,6 +619,8 @@ struct scmi_notify_ops { * be interested to know if they can assume SCMI * command transactions associated to this handle will * never sleep and act accordingly. + * An optional atomic threshold value could be returned + * where configured. * @notify_ops: pointer to set of notifications related operations */ struct scmi_handle { @@ -629,7 +631,8 @@ struct scmi_handle { (*devm_protocol_get)(struct scmi_device *sdev, u8 proto, struct scmi_protocol_handle **ph); void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto); - bool (*is_transport_atomic)(const struct scmi_handle *handle); + bool (*is_transport_atomic)(const struct scmi_handle *handle, + unsigned int *atomic_threshold); const struct scmi_notify_ops *notify_ops; }; -- 2.17.1