From patchwork Fri Sep 22 07:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 143470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5617214vqi; Fri, 22 Sep 2023 07:25:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSGPSvS0eFmHLCGMNdcnSAEAkETuXBSVtnfEvsVdT0BpCtZMiMxDXrMpcBouJ/omSL9UFf X-Received: by 2002:a05:6a20:3206:b0:14d:fefd:a2eb with SMTP id hl6-20020a056a20320600b0014dfefda2ebmr7113990pzc.22.1695392726174; Fri, 22 Sep 2023 07:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695392726; cv=none; d=google.com; s=arc-20160816; b=xsSt1i1pAJDnx1Cx6DWqIjHhehXQ7Bgc+5MyL/wpkYK6xYEYIVYIX7Sm6Ck43Qdq78 W5kCy9p0ShiaV5aE0H4fjOXYXPYngmhWWI4lppcalMS/jxV1I+PA3k1vVxGs74U5sYzf vfpVNkDqe4VSIr0KRoBkYA6p0vsiSlahajm1ItQJAhT1ifkkjX1kj5nccIEjVlP32nfj HOUT4UNjF6Rub8E0yiPvWabpvLpQxZa3KTNJdllNesiRsSsWrlr6+BT2w6YxThOz+4ES SvqjUMDQDsikAOGGsJjo77Nt1YQJMezZHrAP+a58Eg5qrt0J5xRPFtC+vt96Md3zAUBi Mycw== 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=y3si6n+8C/3nGddG/bex4gaYwAJkDU16eps4QpP35QQ=; fh=5rCQDomVZxLXb7yR2oN4iSS3zxUnzGJP2HoQaRzhQu0=; b=boBiRapMn7ZZcDp6fHI5JToHv+vzcCm02eflrh2FPFzQes/7I6teP8jDXSCHyn8xSA VbJ92iodQGZUYwhirQa/i3yfT8uP43QTE2K0GcGhinA/iCTdiYy0QYPvQ70reUTKxiNx ZjhphoBNc+rquorwKKGbbw0oTrsrPlncTDUQ93KH4MwUBYxSPxgFCCM5Ag7MIrAEq2Wp RFu/Jq1PMjDhEpTi0sRVgrB3BNiHypfeKIXyIE85XoSKRzFs+0BjsSz19UexQh2mkhBv b8WRltczWr3KxFp+9nHAzAxcqLx6IL6TiD3yr6XjYLRkstggvDdBBlOeK86OeQGMv8km jQ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kyIF+vCZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i186-20020a6387c3000000b00577a7c39aacsi3898731pge.275.2023.09.22.07.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 07:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kyIF+vCZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B9C1582E332C; Fri, 22 Sep 2023 01:02:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjIVICh (ORCPT + 30 others); Fri, 22 Sep 2023 04:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232287AbjIVIB7 (ORCPT ); Fri, 22 Sep 2023 04:01:59 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B8901BC7; Fri, 22 Sep 2023 01:00:53 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id C4ED51BF207; Fri, 22 Sep 2023 08:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1695369652; 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=y3si6n+8C/3nGddG/bex4gaYwAJkDU16eps4QpP35QQ=; b=kyIF+vCZmNBkMCaBkgjNRE4zeGrnBBBrkKgL/6VDgdBIOH5Pqtgk8xMSbJeYArcE2DKpc5 XGAUsbQvJplQQENA8z9Cv0jsEEvmYC6lMZrFzBPqWkmI9SEi0kpDdo3CobcLoDENPfY4ak LrOqybxZcWdnJmLgSm5c/9PW0fuTQni7qEb2lgI1fR51xQAP16K9LYzJ0kZAaBP70OCOan BUv1qAItqkyQkpWDpLLHcdkEDLSUmQFyJgL1um2/cHtfVBNQYxrf6hzyRjt+xWy/thoOnH VMkhqE9GXOe1FmWodE/OlbUj6z0lOckGftp3yCPbDeg+zEao44u8VsJPBzCeow== 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, Simon Horman , Christophe JAILLET , Thomas Petazzoni Subject: [PATCH v6 22/30] soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime Date: Fri, 22 Sep 2023 09:58:57 +0200 Message-ID: <20230922075913.422435-23-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922075913.422435-1-herve.codina@bootlin.com> References: <20230922075913.422435-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 01:02:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777748123444755940 X-GMAIL-MSGID: 1777748123444755940 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 b63b54ec0a3a..6e22b96b4e7a 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 166484bb4294..2a333fc1ea81 100644 --- a/include/soc/fsl/qe/qmc.h +++ b/include/soc/fsl/qe/qmc.h @@ -40,6 +40,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 {