Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp214473iob; Mon, 2 May 2022 17:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdFgSQ/Yvz0qfzXM4aEFcRwxEEnhOcQrmfUjjBVmfMt6Ht67UkfDUx6vh4cfRiVJa9O3VX X-Received: by 2002:a17:90b:4c88:b0:1dc:60c2:25b2 with SMTP id my8-20020a17090b4c8800b001dc60c225b2mr1902156pjb.133.1651537575934; Mon, 02 May 2022 17:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651537575; cv=none; d=google.com; s=arc-20160816; b=k0Q1uOM6TaVSNU0daeZkYpoW43aIwsnmUMhVUnTJUSfxB1hPxQ9NPePJIVd0jE7bEn eFfO1d04iSMSNNjAfbnEVMu31CyINGNipl+4UkIwadzXcbUv9/k/EXjsKnXAd8aragYl 8xsaOvvHj+vwFe8sXxplFmk19xp1WmIATVfUv4aFUTjjAH+Pk2PpOxOnG2I6+3cryzCh YMmYFc651lNUMwTmc+fnZwPozaU7b0yuVpNJfGad450+p3cGqM7tO/Za4QDtdmW0FE0p csWVNYpiSqswH/K+V8K19aieSkfmg0t+DNmjmYVcqvvQkCdpvmBCpHwfs/o2GKaQsiwy wWyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=M9D/DHKEXRm1uyDsvFqI4SE3s9W9IWPFPqyWww/Mxqc=; b=P764TiHyrvBGEitTDeqw21/5D67ppBByKayJ0vLgbv3F8SEnKUB9AD7wKRYnkTrH99 PC6GpAxOPnT9mY8p+nYxKva+It8QbsI+uPhxufY2S2CIeTdbWGfUfpAZKqrxQ5lIzlpw AziOH/uClL6soGHPa2rgFysBCJ9JfwX5A6KVCc+zxKcnJBaGnfusr88KrTdUte6Jz++j CNmFx8KQawZAhTmItXK+u8iaWXjKF076leNIA/8JfM0n9EZXuozSptcA8CMFK9MrZIjw 7v8Izbqz4cBRB+ldAQIQOw0trOkfsVsGebYcBmkU6uit4xOatw48UAUaHLmKpnbgPYHY ER2A== 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=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h2-20020a056a00218200b004fa3a8e0084si15640539pfi.315.2022.05.02.17.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:26:15 -0700 (PDT) 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=QUARANTINE dis=NONE) header.from=marcan.st Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ADBCB3D1FC; Mon, 2 May 2022 17:21:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346636AbiEBJGs (ORCPT + 99 others); Mon, 2 May 2022 05:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384071AbiEBJGZ (ORCPT ); Mon, 2 May 2022 05:06:25 -0400 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88C25931E; Mon, 2 May 2022 02:02:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hector@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 1D9A0422CC; Mon, 2 May 2022 09:02:51 +0000 (UTC) From: Hector Martin Cc: Hector Martin , Anup Patel , Vinod Koul , Sven Peter , Alyssa Rosenzweig , Mun Yew Tham , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Michal Simek , Arnd Bergmann , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 5/7] mailbox: Rename peek_data to poll_data and fix documentation Date: Mon, 2 May 2022 18:02:23 +0900 Message-Id: <20220502090225.26478-6-marcan@marcan.st> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220502090225.26478-1-marcan@marcan.st> References: <20220502090225.26478-1-marcan@marcan.st> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org peek_data was poorly specified and the documentation implied it should just check for whether there are messages available to be received. The intent is for this function to be usable in atomic context. Just checking for available data is not useful; the subsystem needs to provide some way to poll for (and actually receive) data in atomic context for this to make sense. As one might expect, all existing drivers that implemented the "peek" semantics had zero actual users, since that interpretation of the feature doesn't lend itself to a useful purpose. There is only one driver implementing peek_data as a proper poll: flexrm. That also happens to be the only one with a user. So, rename peek_data to poll_data and fix the documentation to actually describe it properly as a synchronous poll for data. Previous patches already removed the useless implementations, so this only has to fix the bcm driver and client besides the subsystem. Signed-off-by: Hector Martin --- Documentation/driver-api/mailbox.rst | 2 +- drivers/dma/bcm-sba-raid.c | 4 ++-- drivers/mailbox/bcm-flexrm-mailbox.c | 4 ++-- drivers/mailbox/mailbox.c | 25 +++++++++++-------------- include/linux/mailbox_client.h | 2 +- include/linux/mailbox_controller.h | 6 +++--- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Documentation/driver-api/mailbox.rst b/Documentation/driver-api/mailbox.rst index 0ed95009cc30..e4ccafdb1e00 100644 --- a/Documentation/driver-api/mailbox.rst +++ b/Documentation/driver-api/mailbox.rst @@ -27,7 +27,7 @@ Controller Driver (See include/linux/mailbox_controller.h) Allocate mbox_controller and the array of mbox_chan. -Populate mbox_chan_ops, except peek_data() all are mandatory. +Populate mbox_chan_ops, except poll_data() all are mandatory. The controller driver might know a message has been consumed by the remote by getting an IRQ or polling some hardware flag or it can never know (the client knows by way of the protocol). diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index 64239da02e74..841045ecc449 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -223,7 +223,7 @@ static struct sba_request *sba_alloc_request(struct sba_device *sba) * would have completed which will create more * room for new requests. */ - mbox_client_peek_data(sba->mchan); + mbox_client_poll_data(sba->mchan); return NULL; } @@ -555,7 +555,7 @@ static enum dma_status sba_tx_status(struct dma_chan *dchan, if (ret == DMA_COMPLETE) return ret; - mbox_client_peek_data(sba->mchan); + mbox_client_poll_data(sba->mchan); return dma_cookie_status(dchan, cookie, txstate); } diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c index 22acb51531cb..9decb844eff8 100644 --- a/drivers/mailbox/bcm-flexrm-mailbox.c +++ b/drivers/mailbox/bcm-flexrm-mailbox.c @@ -1223,7 +1223,7 @@ static int flexrm_send_data(struct mbox_chan *chan, void *data) return flexrm_new_request(ring, NULL, data); } -static bool flexrm_peek_data(struct mbox_chan *chan) +static bool flexrm_poll_data(struct mbox_chan *chan) { int cnt = flexrm_process_completions(chan->con_priv); @@ -1449,7 +1449,7 @@ static const struct mbox_chan_ops flexrm_mbox_chan_ops = { .send_data = flexrm_send_data, .startup = flexrm_startup, .shutdown = flexrm_shutdown, - .peek_data = flexrm_peek_data, + .poll_data = flexrm_poll_data, }; static struct mbox_chan *flexrm_mbox_of_xlate(struct mbox_controller *cntlr, diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 3e7d4b20ab34..6b13a7047c64 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -200,28 +200,25 @@ void mbox_client_txdone(struct mbox_chan *chan, int r) EXPORT_SYMBOL_GPL(mbox_client_txdone); /** - * mbox_client_peek_data - A way for client driver to pull data - * received from remote by the controller. + * mbox_client_poll_data - Poll for pending messages from the remote. * @chan: Mailbox channel assigned to this client. * - * A poke to controller driver for any received data. - * The data is actually passed onto client via the - * mbox_chan_received_data() - * The call can be made from atomic context, so the controller's - * implementation of peek_data() must not sleep. + * Asks the controller driver to poll for any available data from the remote. + * The data will be synchronously delivered via mbox_chan_received_data(). + * This call can be made from atomic context, so the controller's + * implementation of poll_data() must not sleep. * - * Return: True, if controller has, and is going to push after this, - * some data. - * False, if controller doesn't have any data to be read. + * Return: True if the controller received and has processed some data. + * False if controller didn't have any pending data to read. */ -bool mbox_client_peek_data(struct mbox_chan *chan) +bool mbox_client_poll_data(struct mbox_chan *chan) { - if (chan->mbox->ops->peek_data) - return chan->mbox->ops->peek_data(chan); + if (chan->mbox->ops->poll_data) + return chan->mbox->ops->poll_data(chan); return false; } -EXPORT_SYMBOL_GPL(mbox_client_peek_data); +EXPORT_SYMBOL_GPL(mbox_client_poll_data); /** * mbox_send_message - For client to submit a message to be diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h index 65229a45590f..ccfc81748295 100644 --- a/include/linux/mailbox_client.h +++ b/include/linux/mailbox_client.h @@ -43,7 +43,7 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index); int mbox_send_message(struct mbox_chan *chan, void *mssg); int mbox_flush(struct mbox_chan *chan, unsigned long timeout); void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */ -bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */ +bool mbox_client_poll_data(struct mbox_chan *chan); /* atomic */ void mbox_free_channel(struct mbox_chan *chan); /* may sleep */ #endif /* __MAILBOX_CLIENT_H */ diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 36d6ce673503..70d766e623ac 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -40,8 +40,8 @@ struct mbox_chan; * mode 'send_data' is expected to return -EBUSY. * The controller may do stuff that need to sleep/block. * Used only if txdone_poll:=true && txdone_irq:=false - * @peek_data: Atomic check for any received data. Return true if controller - * has some data to push to the client. False otherwise. + * @poll_data: Poll atomically for received data. Return true if there + * was data available that has been processed. False otherwise. */ struct mbox_chan_ops { int (*send_data)(struct mbox_chan *chan, void *data); @@ -49,7 +49,7 @@ struct mbox_chan_ops { int (*startup)(struct mbox_chan *chan); void (*shutdown)(struct mbox_chan *chan); bool (*last_tx_done)(struct mbox_chan *chan); - bool (*peek_data)(struct mbox_chan *chan); + bool (*poll_data)(struct mbox_chan *chan); }; /** -- 2.35.1