Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6009767pxb; Mon, 14 Feb 2022 13:03:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEVcsMr2Nr6vI/gM321rhslN8uZBfCXgTG1S3zdUo5EMznJ4qUhqUI1GERjaK83/O9Rrz4 X-Received: by 2002:a17:902:cf08:: with SMTP id i8mr640008plg.37.1644872617235; Mon, 14 Feb 2022 13:03:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644872617; cv=none; d=google.com; s=arc-20160816; b=fJitVRchN2nnfDaKDDNdym7rXT0W4ZTZY7FZpAhDIwhgXix7nPqvWe8OMVjAFjNQHD GbodkiOYAbxvuEQEx06q/i9abbRW/OPHVJEPUEAyPuHwgQQ8wV/Dt/nbL2EdhlURzCcV QPy5aiur3UhHJUh329qKw4TyiUc2G+0CoPptcIMxTDjtpuiUDcM0MxZxZua4vX6PxuCA Tww8A0Yu0rejujD7xKc8FiNgBrg57aOFq08DBN90i4SBCOHehJkOEJP2yDDseaSGaa0G vVLIBMfDvDio1MLblGDJnJosmxODdea/SDOA+PCXp8jeXgZROaW2GikjCS5/J3cYJvUH EcgQ== 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=hDfuKDMIA+CSBXQNC4WApHR2TGLhYUg716wkCyameAI=; b=lvY5iIOKhuTupghcFvoazOQGyacMe1aOeP9dvV+ggzVOi0O13lzeJZ0uIyE5JS47kt cfbwLVyhp4Oiypp2xRqHdIC98N+wySEfn/Hxg0YaadNJpbqOX8s1vVqvMLTV95TBnyBt 5+0N5fltS1zNXIyWj8qcSXn7cRWQlB0hnkxgHDzUbxiMogTJrhyKhyjgV6MW0Y59TZrO dPdpbonrMHMyMl9Y6jO7Cxcj137f6u8U88vQaIh0O7IzJZZjcR8Z6t9gia0nTbxlcA56 G63mblzHhAfWxJBSY1GC4i371XcAGR3Stz6Iw+x3SB7PLk6BO6nnWShwIHdpdeyrmD2P PXXg== 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: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k189si782953pgd.200.2022.02.14.13.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:03:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 30DEF1074F6; Mon, 14 Feb 2022 12:25:13 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238111AbiBMT7V (ORCPT + 99 others); Sun, 13 Feb 2022 14:59:21 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238092AbiBMT7O (ORCPT ); Sun, 13 Feb 2022 14:59:14 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D5830532DE for ; Sun, 13 Feb 2022 11:59:07 -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 9AD3B2B; Sun, 13 Feb 2022 11:59:07 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 05BDE3F70D; Sun, 13 Feb 2022 11:59:05 -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 v4 5/8] firmware: arm_scmi: Support optional system wide atomic-threshold-us Date: Sun, 13 Feb 2022 19:58:29 +0000 Message-Id: <20220213195832.27932-6-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220213195832.27932-1-cristian.marussi@arm.com> References: <20220213195832.27932-1-cristian.marussi@arm.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 if supported by the underlying transport at all. Signed-off-by: Cristian Marussi --- v3 --> v4 - renamed DT property to atomic-threshold-us --- 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..0724012a580e 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-us", + &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