From patchwork Wed Jul 26 15:02:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 126464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp486379vqo; Wed, 26 Jul 2023 08:38:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlElqnZwl7LPSbm5wlpFlt1JzdbodG8CYzP4q/uA6B2L9zIaS/ItF20DUKvYSvHwVpUaANtX X-Received: by 2002:a17:902:b68f:b0:1bb:a125:f831 with SMTP id c15-20020a170902b68f00b001bba125f831mr1930397pls.58.1690385909272; Wed, 26 Jul 2023 08:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690385909; cv=none; d=google.com; s=arc-20160816; b=PWoLTQ7Z3PpJFimqbt7JA4CDB3/sxI8D0bOTR+qQhNaFdQgxtABxMb5c6fZY9ljSHJ mctjLknc7OH1VbjVg90jceF6fy2Mrogyd1LH0PUKgoJHFrrxUBuoQxX9BYsdS5k27tac v6xvzkUpt87CpUbXsF+4ORVpbhGS1InmLhsFYSayYzicKXcvjBdy59Lg8EMCVKIfdk6j cdURuuf2jXPX67RHwUKPjCNyobBeJvK+MZ3uvpfWWI+b7qerNlLi4O4nqmunBEq4mWB6 G+Q9hNkn59bSwgmjrMAnZqdo83PvGS2d3vWdcT0DOQq4N5PU9SlVDPnkqhzGccv2DcNS MGJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=opjKFKBBOsi+9FdCPHelcAMCEQhpOPve8gbn6gyMLxE=; fh=OtJVFpZ5Y8/ND7g8QcUIbRSFhG4LznwcYYtG4zWKevM=; b=taEffB3TDpmhsTjoKHdBQYVZMKdGuQTQusN4BM7StErXNa5cCCGa+GCZLfl4ojJUha kLeEmyfLYix0uAyfvy6CkvfO4zIQoM32XHkZuahhkYUNOEiUs2RtQZtgB44t26c0TWHM EPOBkd85fg5guyzQBGuM3YwKt9a2w+IiMOeaolrkgnToLcPiQS8uvKXLopC/mdSwEmw/ w0gI3z/zn03Zxulg7NkfdjJxU0d4SbPAnHlF5kDurlynE3sh49poj2bwKIOmXf/UwQq2 D0e6bEHyl9YYLv6ZxslHFPjRTHrKxmYH2MNi9PaOnxLf6gug3rW1l39aK6iS39LXymkE WMqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D9bQrKDw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a170903018600b001b864d88d85si13840511plg.636.2023.07.26.08.38.15; Wed, 26 Jul 2023 08:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D9bQrKDw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234580AbjGZPFK (ORCPT + 99 others); Wed, 26 Jul 2023 11:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234702AbjGZPEw (ORCPT ); Wed, 26 Jul 2023 11:04:52 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED05C2D49; Wed, 26 Jul 2023 08:04:13 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 5E8B81C001F; Wed, 26 Jul 2023 15:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690383823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=opjKFKBBOsi+9FdCPHelcAMCEQhpOPve8gbn6gyMLxE=; b=D9bQrKDwNbpUA5o6Zp0hiBwf+MWIy/y+M1KiYKOodtNkbrVZ9rEVPmAMY5kJrkzjmwbqnN c623P+YpXzRV0+RQaC0SAvyLZLpHILm9YXAsVE/pWP8N4YyNxR5DThzemGOkBay/2El89w guVJJ1eyvuI7nn7lvaDPnCpT2FADqfT0JeleWJDOpooJnqHz18d62hfcTJKPuvZpGIbfpG yzWC30csXsyvMID3o4LLnwWDLs3bec7nYauWwh229hxV1qYrx2BlfajgyYHqxeZ5YpPN7L /w41tjJjuWuE+YwC5hJLihdfAzmWypEnxx7iHugWoT+HyVrmviS/iRH3jbmyEg== From: Herve Codina To: Herve Codina , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Linus Walleij , Qiang Zhao , Li Yang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Christophe Leroy , Randy Dunlap Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Thomas Petazzoni Subject: [PATCH v2 18/28] soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime Date: Wed, 26 Jul 2023 17:02:14 +0200 Message-ID: <20230726150225.483464-19-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726150225.483464-1-herve.codina@bootlin.com> References: <20230726150225.483464-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772498095638860214 X-GMAIL-MSGID: 1772498095638860214 Introduce qmc_chan_{get,set}_ts_info() function to allow timeslots modification at runtime. The modification is provided using qmc_chan_set_ts_info() and will be applied on next qmc_chan_start(). qmc_chan_set_ts_info() must be called with the channel rx and/or tx stopped. Signed-off-by: Herve Codina Reviewed-by: Christophe Leroy --- drivers/soc/fsl/qe/qmc.c | 51 ++++++++++++++++++++++++++++++++++++++++ include/soc/fsl/qe/qmc.h | 10 ++++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c index b1883b9d2bae..e3953bc07b1f 100644 --- a/drivers/soc/fsl/qe/qmc.c +++ b/drivers/soc/fsl/qe/qmc.c @@ -290,6 +290,57 @@ int qmc_chan_get_info(struct qmc_chan *chan, struct qmc_chan_info *info) } EXPORT_SYMBOL(qmc_chan_get_info); +int qmc_chan_get_ts_info(struct qmc_chan *chan, struct qmc_chan_ts_info *ts_info) +{ + unsigned long flags; + + spin_lock_irqsave(&chan->ts_lock, flags); + + ts_info->rx_ts_mask_avail = chan->rx_ts_mask_avail; + ts_info->tx_ts_mask_avail = chan->tx_ts_mask_avail; + ts_info->rx_ts_mask = chan->rx_ts_mask; + ts_info->tx_ts_mask = chan->tx_ts_mask; + + spin_unlock_irqrestore(&chan->ts_lock, flags); + + return 0; +} +EXPORT_SYMBOL(qmc_chan_get_ts_info); + +int qmc_chan_set_ts_info(struct qmc_chan *chan, const struct qmc_chan_ts_info *ts_info) +{ + unsigned long flags; + int ret; + + /* Only a subset of available timeslots is allowed */ + if ((ts_info->rx_ts_mask & chan->rx_ts_mask_avail) != ts_info->rx_ts_mask) + return -EINVAL; + if ((ts_info->tx_ts_mask & chan->tx_ts_mask_avail) != ts_info->tx_ts_mask) + return -EINVAL; + + /* In case of common rx/tx table, rx/tx masks must be identical */ + if (chan->qmc->is_tsa_64rxtx) { + if (ts_info->rx_ts_mask != ts_info->tx_ts_mask) + return -EINVAL; + } + + spin_lock_irqsave(&chan->ts_lock, flags); + + if ((chan->tx_ts_mask != ts_info->tx_ts_mask && !chan->is_tx_stopped) || + (chan->rx_ts_mask != ts_info->rx_ts_mask && !chan->is_rx_stopped)) { + dev_err(chan->qmc->dev, "Channel rx and/or tx not stopped\n"); + ret = -EBUSY; + } else { + chan->tx_ts_mask = ts_info->tx_ts_mask; + chan->rx_ts_mask = ts_info->rx_ts_mask; + ret = 0; + } + spin_unlock_irqrestore(&chan->ts_lock, flags); + + return ret; +} +EXPORT_SYMBOL(qmc_chan_set_ts_info); + int qmc_chan_set_param(struct qmc_chan *chan, const struct qmc_chan_param *param) { if (param->mode != chan->mode) diff --git a/include/soc/fsl/qe/qmc.h b/include/soc/fsl/qe/qmc.h index 6f1d6cebc9fe..802c161636bd 100644 --- a/include/soc/fsl/qe/qmc.h +++ b/include/soc/fsl/qe/qmc.h @@ -38,6 +38,16 @@ struct qmc_chan_info { int qmc_chan_get_info(struct qmc_chan *chan, struct qmc_chan_info *info); +struct qmc_chan_ts_info { + u64 rx_ts_mask_avail; + u64 tx_ts_mask_avail; + u64 rx_ts_mask; + u64 tx_ts_mask; +}; + +int qmc_chan_get_ts_info(struct qmc_chan *chan, struct qmc_chan_ts_info *ts_info); +int qmc_chan_set_ts_info(struct qmc_chan *chan, const struct qmc_chan_ts_info *ts_info); + struct qmc_chan_param { enum qmc_mode mode; union {