Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4674493ybf; Wed, 4 Mar 2020 08:28:28 -0800 (PST) X-Google-Smtp-Source: ADFU+vuJzf40U8ezExiFXeCouF9c917t6+y+7Sw4Ahu1ZOzMCEtjWs8nENyK/exURchlE66G20hd X-Received: by 2002:a05:6830:110:: with SMTP id i16mr2899928otp.189.1583339308762; Wed, 04 Mar 2020 08:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583339308; cv=none; d=google.com; s=arc-20160816; b=G8+nGCRreVqsyyz5+19zqcHoleBBDcAA4Ya9gDby0uIvGkGj2yYEcKOdfJ+UZJwGSH 6TJo8oYELEvqZz+E85HBghdoGEie9V4naSPjuxmk4DxwZCBzA58yJZMJVyToQSQt/a24 128Bq9U284Ih/fzCtUNHdyqoNAA3I6y28yX5ZtJ+rdZevLsWpHUNLkLdxqJSkKmrOm+M cP5kfnXV4ovtHnZekymmCZRDJPGoBviD2bLMZGg9G66fKsJhRYKBJxIbcwEO/Q2y8uzp euAGeCC7e/WcLjQbpfT/hQD6hNmZVQNNGvHtQdJ43S8VYqdDeCuMZuHoAzrFkaahkDHj adtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=CmYkooA3ckIKjrF/lT+GnuhcBf26loM/FMZSNzLvq9Q=; b=dQ3czh07F60T3yuaGkVOaUxeK2h1BVrSOpN4FiQuYZIWKORbiDROT3pfZLPJMsX3Tj tJL1TCuj/e6c2IcuQ+aA2Zv4/os8xehSCk3y0BOIsJJYB9ZPkCIacSPoD1MolmQAvbcX h58C08NhO65RgeXg1EvJexlHAmGL8x9VOJm6aW6WZReY2yqRV1cuPPUKHZor+2mvVNkz R+zg5JjlcI3jIGgrXQbzGfMAPQAPKvTXljs1xAY0paLNX6nZ58rhyJF7vX6dU6nFiu4w jOeXhsElK2XMCZlEYJhYhz46V1acK2pEsr62xvyw6CuG7kOD797xLf5twgrqDJNLUR81 H7sA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q131si1390861oig.203.2020.03.04.08.28.15; Wed, 04 Mar 2020 08:28:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729843AbgCDQ0h (ORCPT + 99 others); Wed, 4 Mar 2020 11:26:37 -0500 Received: from foss.arm.com ([217.140.110.172]:36528 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCDQ0h (ORCPT ); Wed, 4 Mar 2020 11:26:37 -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 72BFF31B; Wed, 4 Mar 2020 08:26:36 -0800 (PST) Received: from e120937-lin.cambridge.arm.com (e120937-lin.cambridge.arm.com [10.1.197.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6FA803F6CF; Wed, 4 Mar 2020 08:26:35 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, lukasz.luba@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, cristian.marussi@arm.com Subject: [PATCH v4 00/13] SCMI Notifications Core Support Date: Wed, 4 Mar 2020 16:25:45 +0000 Message-Id: <20200304162558.48836-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, this series wants to introduce SCMI Notification Support, built on top of the standard Kernel notification chain subsystem. At initialization time each SCMI Protocol takes care to register with the new SCMI notification core the set of its own events which it intends to support. Using the API exposed via scmi_handle.notify_ops a Kernel user can register its own notifier_t callback (via a notifier_block as usual) against any registered event as identified by the tuple: (proto_id, event_id, src_id) where src_id represents a generic source identifier which is protocol dependent like domain_id, performance_id, sensor_id and so forth. (users can anyway do NOT provide any src_id, and subscribe instead to ALL the existing (if any) src_id sources for that proto_id/evt_id combination) Each of the above tuple-specified event will be served on its own dedicated blocking notification chain, dynamically allocated on-demand when at least one user has shown interest on that event. Upon a notification delivery all the users' registered notifier_t callbacks will be in turn invoked and fed with the event_id as @action param and a generated custom per-event struct _report as @data param. (as in include/linux/scmi_protocol.h) The final step of notification delivery via users' callback invocation is instead delegated to a pool of deferred workers (Kernel cmwq): each SCMI protocol has its own dedicated worker and dedicated queue to push events from the rx ISR to the worker. Based on scmi-next 5.6 [1], on top of: commit 5c8a47a5a91d ("firmware: arm_scmi: Make scmi core independent of the transport type") This series has been tested on JUNO with an experimental firmware only supporting Perf Notifications. Thanks Cristian ---- v3 --> v4: - dropped RFC tag - avoid one unneeded evt payload memcpy on the ISR RC code path by redesigning dispatcher to handle partial queue-reads (in_flight events, only header) - fixed the initialization issue exposed by late SCMI modules loading by reviewing the init process to support possible late events registrations by protocols and early callbacks registrations by users (pending) - cleanup/simplification of exit path: SCMI protocols are generally never de-initialized after the initial device creation, so do not deinit notification core either (we do halt the delivery, stop the wq and empty the queues though) - reduced contention on regustered_events_handler to the minimum during delivery by splitting the common registered_events_handlers hashtable into a number of per-protocol tables - converted registered_protocols and registered_events hastable to fixed size arrays: simpler and lockless in our usage scenario v2 --> v3: - added platform instance awareness to the notification core: a notification instance is created for each known handle - reviewed notification core initialization and shutdown process - removed generic non-handle-rooted registration API - added WQ_SYSFS flag to workqueue instance v1 --> v2: - dropped anti-tampering patch - rebased on top of scmi-for-next-5.6, which includes Viresh series that make SCMI core independent of transport (5c8a47a5a91d) - add a few new SCMI transport methods on top of Viresh patch to address needs of SCMI Notifications - reviewed/renamed scmi_handle_xfer_delayed_resp() - split main SCMI Notification core patch (~1k lines) into three chunks: protocol-registration / callbacks-registration / dispatch-and-delivery - removed awkward usage of IDR maps in favour of pure hashtables - added enable/disable refcounting in notification core (was broken in v1) - removed per-protocol candidate API: a single generic API is now proposed instead of scmi_register__event_notifier(evt_id, *src_id, *nb) - added handle->notify_ops as an alternative notification API for scmi_driver - moved ALL_SRCIDs enabled handling from protocol code to core code - reviewed protocol registration/unregistration logic to use devres - reviewed cleanup phase on shutdown - fixed ERROR: reference preceded by free as reported by kbuild test robot [1] git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git Cristian Marussi (10): firmware: arm_scmi: Add notifications support in transport layer firmware: arm_scmi: Add notification protocol-registration firmware: arm_scmi: Add notification callbacks-registration firmware: arm_scmi: Add notification dispatch and delivery firmware: arm_scmi: Enable notification core firmware: arm_scmi: Add Power notifications support firmware: arm_scmi: Add Perf notifications support firmware: arm_scmi: Add Sensor notifications support firmware: arm_scmi: Add Reset notifications support firmware: arm_scmi: Add Base notifications support Sudeep Holla (3): firmware: arm_scmi: Add receive buffer support for notifications firmware: arm_scmi: Update protocol commands and notification list firmware: arm_scmi: Add support for notifications message processing drivers/firmware/arm_scmi/Makefile | 2 +- drivers/firmware/arm_scmi/base.c | 116 +++ drivers/firmware/arm_scmi/common.h | 12 + drivers/firmware/arm_scmi/driver.c | 118 ++- drivers/firmware/arm_scmi/mailbox.c | 17 + drivers/firmware/arm_scmi/notify.c | 1471 +++++++++++++++++++++++++++ drivers/firmware/arm_scmi/notify.h | 78 ++ drivers/firmware/arm_scmi/perf.c | 135 +++ drivers/firmware/arm_scmi/power.c | 129 +++ drivers/firmware/arm_scmi/reset.c | 96 ++ drivers/firmware/arm_scmi/sensors.c | 73 ++ drivers/firmware/arm_scmi/shmem.c | 15 + include/linux/scmi_protocol.h | 110 ++ 13 files changed, 2345 insertions(+), 27 deletions(-) create mode 100644 drivers/firmware/arm_scmi/notify.c create mode 100644 drivers/firmware/arm_scmi/notify.h -- 2.17.1