From patchwork Thu Dec 22 14:15:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13080023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6F862C4332F for ; Thu, 22 Dec 2022 14:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RrNRNntN3uM9m1NvD60YoGE/b4zlq/peVu0+r4rOqAs=; b=3oO6CrBAZTAqnS TgBom902qZyHtAgMBZecn32ncY6Tuv0dRTV/qufgovsgyJUbwor097H0Ftgn/LxPnMhuQzf8ydBJj ggzExB9XXhINkzxVrvSidEiw2CsyveUh6SE8wtJpxKNmmvxxpUFgUgQ5i4GyvNZlkEXX/QddxImJE fPbu6ZR8RUsVJkjNKKmd7xn0MsWXqHVE23E8QjJRYbEp/vkvikY+7F0XfHBPsD+FBBK7D8l5AZqHE okbuRm8mEUkDjf921Q2k+zIXlrWh2ApDdEuzwPW2c77/fkEdAJlKUfwajpjq39lw4XgbtGz9UXwq4 DZbLT/veBB5CsZNd/4qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8MgL-00D2MT-4K; Thu, 22 Dec 2022 14:36:26 +0000 Received: from mout.kundenserver.de ([212.227.126.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8MN8-00CrNZ-1x; Thu, 22 Dec 2022 14:16:36 +0000 Received: from stefanw-SCHENKER ([37.4.248.22]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MFsER-1p5s3E1lAV-00HLB2; Thu, 22 Dec 2022 15:16:23 +0100 From: Stefan Wahren To: Greg Kroah-Hartman , Florian Fainelli Cc: linux-staging@lists.linux.dev, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Umang Jain , Phil Elwell , Stefan Wahren Subject: [PATCH] staging: vchiq_core: Add comments to remote event parts Date: Thu, 22 Dec 2022 15:15:53 +0100 Message-Id: <20221222141553.138563-1-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:W5Nl+lrIYpBoJ8xhdZ+/1NRR3o2mgPu4MEbmk/LtK/sX0SEhPWV l68LEjxWd2UhWWnv3lyN6O0g/jadSaSNEqD1lNCRu+bvTv9QzL8KyHDd7yltPKDZW7WJM3I 77Dsb6BbzUCDDyf+BYzuAHTPHbrbQcM/yKmtlnEBeu2Rpj1fk6ha06UHv0YioXtBzlROh5N svjD3lF50vRNMG7/EEpMw== UI-OutboundReport: notjunk:1;M01:P0:zbymciysjy0=;/q2w0GUPnkREwqyFizDDbzHy9eO 0BirmsQOya+Gf/MCmqVG3boAx3F5TAH8HGDi0rtLswuFfikrIdG8RLpq1AwdxiEeUAfMfcHvw /E80t8XoiwaO1s/3d+Fqq2Wki4nI+IApWhqHyZur2uEr4wEG3gPUn5iwiFTXWPfRuFgyusaag eh0E68vl7zchM+GUE5Azrcqn0Zz1jSqfB5RBPLZ0ip9yMmu0C/NbHKTQttvGeAMwb6fquC+Y/ rkStbUOUQ3P1mgXaGSW62uyh2tgOfAYyUA/kvA7UV0QbxutSg7FfEnGiELUyeuglzf5Lf9Z+d pogZ3YLZAzbSVtOA0cpuxKs5xLQ6jQV+Bn7BWTEv8jV5+57RRVyG5js/yAx17vkZhBOfJj8xj OalTFr5Phf+R/4We9GnD4FEPCoVJlQWwgo7zvSBSrABjFUhL0Qn7q2q6GhOmHIbaHMAPr0wrM TjB87nP3sWPcjarz050dN2rFlcUrsFv7WFB5u2ZPOtOFmFgXK8GQhzC/+PpFnOCShRIt4mytX WaWxYfX1K8Diht98/rfCSNenSODKvR0Q5+INGTCNWlPEQzrELwcE80vh6ppv3O+qleU4qC4Vi lTlmcxvdHHnawuNasfVqHpnRUwJ4EyyjdqV46SNsdrd0NKZnEK5yuMRCbqW4Z41nIMDoxK32B cKofcSBGnZ08Phnp1bZxe3ecfwvPsgS4AeSQt10HVw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221222_061634_453452_8D715783 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Phil Elwell struct remote_event and the related functions remote_event_*() provides a higher function between ARM core and VPU. It's very helpful for a reviewer to have explaining comments about these parts. Signed-off-by: Phil Elwell Signed-off-by: Stefan Wahren --- .../interface/vchiq_arm/vchiq_core.c | 10 ++++++++++ .../interface/vchiq_arm/vchiq_core.h | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 45ed30bfdbf5..2571a3742745 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -498,6 +498,7 @@ vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) vchiq_platform_conn_state_changed(state, oldstate, newstate); } +/* This initialises a single remote_event, and the associated wait_queue. */ static inline void remote_event_create(wait_queue_head_t *wq, struct remote_event *event) { @@ -536,6 +537,10 @@ remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) return 1; } +/* + * Acknowledge that the event has been signalled, and wake any waiters. Usually + * called as a result of the doorbell being rung. + */ static inline void remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event) { @@ -544,6 +549,7 @@ remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event) wake_up_all(wq); } +/* Check if a single event has been signalled, waking the waiters if it has. */ static inline void remote_event_poll(wait_queue_head_t *wq, struct remote_event *event) { @@ -551,6 +557,10 @@ remote_event_poll(wait_queue_head_t *wq, struct remote_event *event) remote_event_signal_local(wq, event); } +/* + * VCHIQ used a small, fixed number of remote events. It is simplest to + * enumerate them here for polling. + */ void remote_event_pollall(struct vchiq_state *state) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 8b4a38f5b3f2..fd6c95e91436 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -166,6 +166,24 @@ struct vchiq_bulk_queue { struct vchiq_bulk bulks[VCHIQ_NUM_SERVICE_BULKS]; }; +/* + * Remote events provide a way of presenting several virtual doorbells to a + * peer (ARM host to VPU) using only one physical doorbell. They can be thought + * of as a way for the peer to signal a semaphore, in this case implemented as + * a workqueue. + * + * Remote events remain signalled until acknowledged by the receiver, and they + * are non-counting. They are designed in such a way as to minimise the number + * of interrupts and avoid unnecessary waiting. + * + * A remote_event is as small data structures that live in shared memory. It + * comprises two booleans - armed and fired: + * + * The sender sets fired when they signal the receiver. + * If fired is set, the receiver has been signalled and need not wait. + * The receiver sets the armed field before they begin to wait. + * If armed is set, the receiver is waiting and wishes to be woken by interrupt. + */ struct remote_event { int armed; int fired;