From patchwork Thu Sep 28 07:06:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 145850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3153538vqu; Thu, 28 Sep 2023 01:21:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8mGDwfYb34IMDbhjfJM38QMmpdkP/jGC/hXZCl4J4cAo3/WAQl4Xv+9uD7HqatTN+l6Yp X-Received: by 2002:a05:620a:4014:b0:774:2c35:379d with SMTP id h20-20020a05620a401400b007742c35379dmr644039qko.7.1695889265700; Thu, 28 Sep 2023 01:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695889265; cv=none; d=google.com; s=arc-20160816; b=kLzqPzE6OSDQ35SwpsiF/SV51nkcLHV/sdrVw7dDgUdutthxQsR+lu3yiIeHTvoKX+ 9Qkq0RI4SbPbPDpjyABtcLED6qDjUQRw0UnvfIVxuZy3Ij5Yxf6jDRl8uc1gEZ/7oAIh KPMQtpMhJ10QyXLT3ng4q8iF4bhnUXQdmMu+rRWPEBJ/ILl+hoWQ0kQLewXSAieLBcx+ fru/j+DyFzqjvnO1kbPgD2wWJpiIDanp7BsZEIoJmCYyH4Ii6kRGXLMZnjVhMKz68B/c lMDbW+wpyp9WkSo+XiEpR5JXTr76672kiOcCdp61cwr8orkUm6VYimeewxnOL3XhlO7+ T/NA== 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=8Kc64rxAF0/ep7JtUzveSO6N9QMBWtHyiJ9nqNn2Uww=; b=DCpMF0XTgx1LLKhdeTvz4Pxd+Fei1g9vv1buODUWsFAQEZUpqg0kGrcEO1th/FNbqp pi4gRA3Upko9K+L7Yf6Xu+ORfSF9vKZrqqOAYe2kY8ViRSSBUFAdDzAFDaKonOictA+6 KqEFZ4k9Jq84toac50JFWcrbJ0u2UQ610kFiVcpoFSeZ+8hbWzOytaf825uxXOei7/lf yC+M1RETPjQ+wz0wPwZzGUCgCPBdTOjLJkzqHdmQDPaVqBJx69sNQJcc+voj2JgnxkFk KgxbIHMcNucXmxBKuUeb8bh6i9o1ypvjRnurRh/JhFRixm8XKvNmtwPCEsOBx0SuktcC Bk0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="MXygfz/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j190-20020a6380c7000000b0056b024a4dd0si17660981pgd.614.2023.09.28.01.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 01:21:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="MXygfz/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 0AF3D8071063; Thu, 28 Sep 2023 00:11:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231370AbjI1HKM (ORCPT + 20 others); Thu, 28 Sep 2023 03:10:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbjI1HKG (ORCPT ); Thu, 28 Sep 2023 03:10:06 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 924461A3; Thu, 28 Sep 2023 00:08:28 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 1BA3120003; Thu, 28 Sep 2023 07:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1695884905; 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=MXygfz/dCjtEhx/9Xq3QOPW+SLgrnOvKBaOjESPIijmoKkdvLlpHMOBdVdtOF/BhqTrH41 jGU2dXX8iERTlomJNTERVgQ4Os7xekP92Gz/riy7/cXho3vt15UYgNHz580G8haPVK+bzI i6gSaRraILTMYTcjKpl/L96sHjdi8SZQwStpm09rCLi4bz1BMDi4biB+66eT91+kRTMpsb XqFQOts/gYW6u1oTzks4KY1HIcYX+eAH+TfPFJZ1UZZ9ejXi4AP0Pbdy+Es822vddM9F8f cZNTBeJgeBefE2rCj5pRfNydkse7Yl3v4edR92pl/3O8rb8vXVN5IULQeVJB6w== From: Herve Codina To: Herve Codina , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Rob Herring , Krzysztof Kozlowski , Conor Dooley , 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 v7 22/30] soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime Date: Thu, 28 Sep 2023 09:06:40 +0200 Message-ID: <20230928070652.330429-23-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928070652.330429-1-herve.codina@bootlin.com> References: <20230928070652.330429-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 00:11:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778268782493664702 X-GMAIL-MSGID: 1778268782493664702 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 {