From patchwork Wed Nov 15 14:39:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 165424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2583182vqg; Wed, 15 Nov 2023 06:43:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoYoB129A2Y3kQJUtNZkVVT3mDDMY5ZufTy4Qsk5BIXxPXfDWyrhTVLE17I+48IwEPU+Mu X-Received: by 2002:a17:902:ea10:b0:1cc:4402:9e7c with SMTP id s16-20020a170902ea1000b001cc44029e7cmr7535794plg.15.1700059390371; Wed, 15 Nov 2023 06:43:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700059390; cv=none; d=google.com; s=arc-20160816; b=e3uRbaolzLajHNkr8R6oimf14juRswzvKQ4+gJ3slQX6ARcmFA8opJlF2FnllWI6aQ it0QjNsxV57zlQgh3FDaIziG5B+MX8xBUMX6RykTZct6KuDhcQcGBOi/pno/X8Y8vsfq Xo8LF4kgZ/IhymK3qoBnisZarOiWYa4jKdSfJc4cDLnnrEce4TB76XA1DuhSjzxuHTt7 Zy4Agziw1rIWEzvqINzWz4xVYmAgWnqQnTIiW8CjaXA1QIOJIhfOksgCyKsYzB/8ZdA7 BuDUvuzmP05zNzk/z43nDZPhhOqZpF1d6MpGlRoTwGlZ+QnePiBF9AFNkSGTAFoW7h1h rMBg== 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=Lmi371X8x5jONZdY02Hgc0h3cbtYVrOzGwTzevjo8JI=; fh=5rCQDomVZxLXb7yR2oN4iSS3zxUnzGJP2HoQaRzhQu0=; b=v6dci/pXZr1TEtsKPjrMPnAzV5IuuC2xyIXf8AC4iYmNrzuA1/NAy0Guo6+bCKFha5 RkYShtjUg+o6JTxZ2+Rf5H+BQ8uNvXNBqNaV8QUX1ZB8a7dP9W1BS/0Lc5RpB3hffikg NpNG1nl/lkBajahcZ1BpShkvPwg3VUS3vcZSg4h05YA0NkzTY1wpLIwJetrSMf4OZ7x0 po1LZtJlHIoOkWAdEtFaoJuEI3xoVlGDPHJ/QOa/TbPNdHVac6+Lf1aX0aV+C5yr8VL9 bQRPm3gOL/ficqKISB7jqSFwGdeRwI3JI6k0SlZPMMMzrkCcgs6ovZPoue3a1iegos0T J+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YIovTjR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ju22-20020a170903429600b001cc13895130si9522622plb.632.2023.11.15.06.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 06:43:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YIovTjR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id E171181D2AC6; Wed, 15 Nov 2023 06:42:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344307AbjKOOmD (ORCPT + 29 others); Wed, 15 Nov 2023 09:42:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344271AbjKOOlZ (ORCPT ); Wed, 15 Nov 2023 09:41:25 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C5E51994; Wed, 15 Nov 2023 06:40:48 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPA id 38F37FF821; Wed, 15 Nov 2023 14:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700059246; 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=Lmi371X8x5jONZdY02Hgc0h3cbtYVrOzGwTzevjo8JI=; b=YIovTjR6KDKFeKbj1xQjlGXKXNBC4nJeWOnKVu1UIzk3NJXa1epixEqeIDb/f3+CtWMojN fmKbcxsAIyxvnwtCZuryiLJao0k7ddmCGsa+oBw38NWmrm9YpLafSPUVn1EWrw1Rc94tw3 S0UtH33KmnimJ2BbQtp/dP22bG3dy2Kg4mBXZWOzPlZzyoV94vg72YlmcEiO90H3z6hW9k xRPhigqOMszakE/Ei5WtQa5SZt7t1fPbAcGRcIyo5cE3eQA8uRY/S9kspXeKuB43N4ZbN7 /fMomjCvKkoaxoo+XPgcWjIgyCNfca9tCpl9NvdpjAa+syMRPDcqkLHciPdGgQ== 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 v9 19/27] soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime Date: Wed, 15 Nov 2023 15:39:55 +0100 Message-ID: <20231115144007.478111-20-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115144007.478111-1-herve.codina@bootlin.com> References: <20231115144007.478111-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 06:42:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782641475306742318 X-GMAIL-MSGID: 1782641475306742318 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 73903ce31695..79fe79b9464f 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 {