From patchwork Tue Jul 25 09:23:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 125493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2377820vqg; Tue, 25 Jul 2023 03:42:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlHnQPeXRFo80nEmySoaDNs7ToLi09jo9EMjsITMX/1LYJyd92w0g91SHL+kbfIBzcZXOmdt X-Received: by 2002:a17:903:247:b0:1b9:e591:db38 with SMTP id j7-20020a170903024700b001b9e591db38mr11789596plh.8.1690281749731; Tue, 25 Jul 2023 03:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690281749; cv=none; d=google.com; s=arc-20160816; b=jdKvB7BApsThKaKB2i1vCotQvjJWQkp5HIZY5gg/xPMKHK8PZnQOfmZyZUPX2yGx5I bkahKNaGPDv9GFs4PqdJe0GVkwdZzroCNtlIeOALW6GgV4bYLDzKM7yzJc95v7CV8Hot MUvXvVK3JRsC1uWDp9G28YZqZB/YUoSuV8F8A+rmxiKk9Osmu2kInt84C1uyYiHtqqAZ mTykKQ7vMAHZp5JpN5CG30yc8Zs2BNsZrVmJnkki/pzb5Veu9NWnF6j7maYJrdVgpV/m RbRa8g0DUazem+dMD/DfKJV+JeCvU/k805sYwL5A6yOgbjWCcGkaXarp59X1H0elfkVb OPug== 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=JrgfM7YPwQ6DvXehi/1uSGzC/wkWE7yY5YLuj3I7fTU=; fh=j5z+1OhFuGBFoHpqsKfNW8PvbyYDiDyztgOSDrYZWKg=; b=AN8tG6PMuCwsd3ScEwRjUXIrlM5yq0hPSyRwFd3bzz7MDHAqoE2n1Tpv1YVtlGK0R9 IXXp1Tr/smkIEBld6R0m3r/RZjArIj0+iggFaX4D8gKO6BW1XhPjcPEhD/gGKWgCBCpk fazbZrHyrmbOPqJgAHpvmi63tM54WpL/8QB/9xuVYhNXUozPOY35Tr1vOoBlPBY7xo9/ t14XDAcOXt/yBoX2kydarWWMmjfUCU65xpHfWL1Vw8Q5W/G68/09mp8EC3YccTMfTDlq q7Wm7iVk8gCR4C+JAYVXOahSAXeEWSZghzEmyENR1FfLtLaoPrqd4iNmiAxchNcGtHzn pCDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YL6XEI1J; 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 n9-20020a170903110900b001b876cb3e53si11830573plh.211.2023.07.25.03.42.16; Tue, 25 Jul 2023 03:42: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=YL6XEI1J; 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 S233102AbjGYJ1c (ORCPT + 99 others); Tue, 25 Jul 2023 05:27:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233082AbjGYJ0y (ORCPT ); Tue, 25 Jul 2023 05:26:54 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38E1E1BEC; Tue, 25 Jul 2023 02:25:45 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 2D83D40014; Tue, 25 Jul 2023 09:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690277139; 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=JrgfM7YPwQ6DvXehi/1uSGzC/wkWE7yY5YLuj3I7fTU=; b=YL6XEI1JXSIiPOplXN6yWpOny004KkxWIgN06pR283/Y3El3VpeJA/qUo+pctPMSj+rm5t KgiKbfLKZ6e0/ZmVTahvfcxCvSBLhN0prrHwKRjvPS6rACw/Fif86iGsaq46G2NmbnZIWi Lpvxb3kamMWvuiSTTzES1jjnwUGdfLGHjLBO0iMl25uPex3Gqr2OjWxNwL9iK921cHUeav X2dJUhaD+HLZ+LIfWAHkvnRXcGqv7/42PCXAjyX2DI4ieauThddCU8iQjBqNUTCdzjOyo9 M1SgXPDe0XADXIYCg/MMuO68m3JiGG/4HFrPy+5GZMx3UoUmZyh2ZhEqopM1Xg== 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 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 16/26] soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime Date: Tue, 25 Jul 2023 11:23:52 +0200 Message-ID: <20230725092417.43706-17-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725092417.43706-1-herve.codina@bootlin.com> References: <20230725092417.43706-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_H3,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: 1772388876236528657 X-GMAIL-MSGID: 1772388876236528657 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 15872d3e4992..a90b3097722f 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 {