From patchwork Fri Mar 27 14:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 11462487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E279161F for ; Fri, 27 Mar 2020 14:38:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09972206F2 for ; Fri, 27 Mar 2020 14:38:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h2zhU0Gw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09972206F2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zyury802ChWGlweGkJ7+iQ95Ug6a++XzW0ipJQ13GPI=; b=h2zhU0GwS5Jvimp6WP2RVu8V7D rDXUUfBtpi90lgHTsfbvW8LBR7V2l6nPStnXrt5WX0vDWg7FIP7T7gDvPSuUX66vcOXFKtTwF6yf4 82sERutgDxq1fg1L9WPUTzuObOXainBXPK7gD0gwI3+OX7YYYoQmKQi5+YuxxLVaR4kKtvMcWKfTW b7hAB3GrOhvH4QtBJV4fwYP8h2c5i+Xkwwv59l2GIo1YMqF2JkTejKrq8zoHxEJU24pBY38XOhg0x 6A8eWal34a8dxWnDsyoxwZegMcTyYjhyEQTy5DrXXktSs/5T0kr2Huf/0NAAkR5xD+ICSv0ak1esB DeaK9GOw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHq8J-0000Mw-LU; Fri, 27 Mar 2020 14:38:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHq4c-0004JP-8X for linux-arm-kernel@lists.infradead.org; Fri, 27 Mar 2020 14:35:04 +0000 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 150651042; Fri, 27 Mar 2020 07:34:57 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 06FAB3F71F; Fri, 27 Mar 2020 07:34:55 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 08/13] firmware: arm_scmi: Enable notification core Date: Fri, 27 Mar 2020 14:34:33 +0000 Message-Id: <20200327143438.5382-9-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200327143438.5382-1-cristian.marussi@arm.com> References: <20200327143438.5382-1-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200327_073502_473003_2FDDE498 X-CRM114-Status: GOOD ( 11.84 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan.Cameron@Huawei.com, cristian.marussi@arm.com, james.quinlan@broadcom.com, lukasz.luba@arm.com, sudeep.holla@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Initialize and enable SCMI Notifications core support during bus/driver probe phase, so that protocols can start registering their supported events during their initialization. Reviewed-by: Jonathan Cameron Signed-off-by: Cristian Marussi --- V3 --> V4 - simplified core initialization: protocols events' registrations is now disjoint from users' callback registrations, so that events' generation can be enabled earlier for registered events and delayed for pending ones in order to support deferred (or missing) protocol initialization V2 --> V3 - reviewed core initialization: all implemented protocols must complete their protocol-events registration phases before notifications can be enabled as a whole; in the meantime any user's callback registration requests possibly issued while the notifications were not enabled remain pending: a dedicated worker completes the handlers registration once all protocols have been initialized. NOTE THAT this can lead to ISSUES with late inserted or missing SCMI modules (i.e. for protocols defined in the DT and implemented by the platform but lazily loaded or not loaded at all.), since in these scenarios notifications dispatching will be enabled later or never. - reviewed core exit: protocol users (devices) are accounted on probe/ remove, and protocols' events are unregisteredonce last user go (can happen only at shutdown) V1 --> V2 - added timestamping - moved notification init/exit and using devres --- drivers/firmware/arm_scmi/driver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 868cc36a07c9..5c43d82e3260 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -26,6 +26,7 @@ #include #include "common.h" +#include "notify.h" #define CREATE_TRACE_POINTS #include @@ -204,11 +205,13 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer) static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr) { + u64 ts; struct scmi_xfer *xfer; struct device *dev = cinfo->dev; struct scmi_info *info = handle_to_scmi_info(cinfo->handle); struct scmi_xfers_info *minfo = &info->rx_minfo; + ts = ktime_get_boottime_ns(); xfer = scmi_xfer_get(cinfo->handle, minfo); if (IS_ERR(xfer)) { dev_err(dev, "failed to get free message slot (%ld)\n", @@ -221,6 +224,8 @@ static void scmi_handle_notification(struct scmi_chan_info *cinfo, u32 msg_hdr) scmi_dump_header_dbg(dev, &xfer->hdr); info->desc->ops->fetch_notification(cinfo, info->desc->max_msg_size, xfer); + scmi_notify(cinfo->handle, xfer->hdr.protocol_id, + xfer->hdr.id, xfer->rx.buf, xfer->rx.len, ts); trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id, xfer->hdr.protocol_id, xfer->hdr.seq, @@ -771,6 +776,9 @@ static int scmi_probe(struct platform_device *pdev) if (ret) return ret; + if (scmi_notification_init(handle)) + dev_err(dev, "SCMI Notifications NOT available.\n"); + ret = scmi_base_protocol_init(handle); if (ret) { dev_err(dev, "unable to communicate with SCMI(%d)\n", ret); @@ -813,6 +821,8 @@ static int scmi_remove(struct platform_device *pdev) struct scmi_info *info = platform_get_drvdata(pdev); struct idr *idr = &info->tx_idr; + scmi_notification_exit(&info->handle); + mutex_lock(&scmi_list_mutex); if (info->users) ret = -EBUSY;