Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1252456rwb; Wed, 26 Jul 2023 09:37:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEf/hlfyC45SvBOMALHCb759yk7DXkDvlpNVeeL8E24VY4npG10E0X/TQbVewGAG2ut4c1u X-Received: by 2002:a05:6a20:9388:b0:13b:9ff3:f52e with SMTP id x8-20020a056a20938800b0013b9ff3f52emr2497111pzh.56.1690389470507; Wed, 26 Jul 2023 09:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690389470; cv=none; d=google.com; s=arc-20160816; b=cIlYCMEizi3SyaJI+YhHxaL7Ei80mu/0axkbhzJZZKlBeRBjA1YcudbY+rRRv/3qed pKXnvwU3cdDV6Rdl3OnJ9T3qD8hb2KM69nWNYz8ADws9dTK4u1xgdWA/qh8qHJnN0M/b QEmf3EqPCafB+l2rv84no6YmxPjyOJj3r5KuvMj1/OTA0bmQUKhcg1B0mRmK0zNmx3xI knpEWJlS+5XiGPi2AsexsUccBaT/vdpOdDB0Ecz37QpVgmA9g8heRAbxmmKX/Q/l4xWA TwuoHZqCJDVVp1ijAOBOLfFnQljdVtEAgRqlP962RSHLsR2vCHbyuQc2svorBFofBysw adUw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k192-20020a636fc9000000b0055bc97cc885si12956427pgc.614.2023.07.26.09.37.36; Wed, 26 Jul 2023 09:37:50 -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 S234713AbjGZPFK (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 Content-Transfer-Encoding: 8bit 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 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 --- 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 { -- 2.41.0