From patchwork Tue Nov 28 14:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 170812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3947422vqx; Tue, 28 Nov 2023 06:09:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IETZe70IbvpDtonJAMl0MZ/i9EY7BzvnLrsL6X0zXGWvvcmY1URSRxpKQfo9Sj+BF990qnk X-Received: by 2002:a05:6871:e493:b0:1fa:2d82:b89b with SMTP id pz19-20020a056871e49300b001fa2d82b89bmr14513423oac.10.1701180585135; Tue, 28 Nov 2023 06:09:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701180585; cv=none; d=google.com; s=arc-20160816; b=REw0nQDhQjIjw6U/juctd8chR9JpbIW/oxtj8Rqm07sPCDmuOJFtD9tYIl+vedXMN9 d6hqIphKHUpURXcbE+lJjCoGeThhK/vDMnk/NX2KNg7sMbYZt9lP0Fg28hZoAUWYRAQJ mEjNHeUKoYdV1ovx/0GY82V+Y/PRLKNlOS+lFGj9gdeY5fF418CJrV4l7Jp4q68DQ9z1 kJg4OKjpJMJRG3QKwX6iW7pvcmLwEmc5LRA+b9rm29jXexvBhnjbUkTTGkimxknuWGNE e+H6m8DrnTVq+4FnTnE96ggUAjEvbdOLpNbS1OT6WXHocl62HwJdDMvkyk3zlq36wIxq FWyA== 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=qB5PQIsjg4vNdEztMunF8K802tA8yt3Tver1m2WVF68=; fh=vamCZaQ7EeQQjV+Jpg1PpgbwecLJumQNdtvzT0FcvGs=; b=Sy4SFJy6jH8yD0aNSXCOenu9bKHr02o8fKeIxHoK8IDgPWvqSrhuX2OS1as7aC1tdV E4Z0lhIOFvpPvkXahGqQheoQ5WIoZdCfD4KDRddQDOb6LCJFGQG2IRoGx1qlcW+QgkmG Wi81NG/EgfKIqqvZPXo/3iEV6CCVj8IiDIkGlvZtQQbN+c8jbaP5CJdO6EGezDeTncyN H0K4kX85IJDEVFyRRftUGxT0/Ujpc8i6qW+L66CvgB7ibTvWj5YWSLfI7rlStdsPKOsX Nn/H7Gn8bb7GoKJbMe8zkur6RnksYhPdWdj89ekNQuLpdMn9PRuJc2RqSjA1zcD7h5H9 KM9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ed6RUCNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id os28-20020a0568707d1c00b001f9dbbefee7si4637059oab.159.2023.11.28.06.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:09:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ed6RUCNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id ED3FB8225CA9; Tue, 28 Nov 2023 06:09:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346298AbjK1OJT (ORCPT + 99 others); Tue, 28 Nov 2023 09:09:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346133AbjK1OIi (ORCPT ); Tue, 28 Nov 2023 09:08:38 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E24C519B3 for ; Tue, 28 Nov 2023 06:08:40 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPA id D33656000B; Tue, 28 Nov 2023 14:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701180519; 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=qB5PQIsjg4vNdEztMunF8K802tA8yt3Tver1m2WVF68=; b=ed6RUCNm7a7brdsSg9wc5Qc1Y1ptEjdyXGcpjOjS8tt9TPY7J1Zm00ocuG+1r+Aj5mjkLn 8k01XwTM9iM8kgXPBgG1oz/1iVQ95LdYUxkaogcDe9qI5yKtssOfA9kKjrqAZAb4O7wQUD d1/mkVaUE0N5ZxrRG6OVDlgG2LwKZzKGA2y4pRXUNSq8llJqTSES3uPQkp433T9LVyWsjc Mze/Z6YlVrBgq4G8ipe32F4IIGbwoh4ZVRJRRr9/HS9N/iaJHiTxmiZ7X41sKgOJIlTxoe ZclZCzDritqoGY6QeqQcz/8FN3HJ1XBCIVJJBopoz1wMS7igDPecTgua1Bdg5A== From: Herve Codina To: Herve Codina , Qiang Zhao , Li Yang , Jakub Kicinski , Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Christophe Leroy Cc: Arnd Bergmann , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni Subject: [PATCH 17/17] soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime Date: Tue, 28 Nov 2023 15:08:16 +0100 Message-ID: <20231128140818.261541-18-herve.codina@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231128140818.261541-1-herve.codina@bootlin.com> References: <20231128140818.261541-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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:09:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783817133502276252 X-GMAIL-MSGID: 1783817133502276252 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 {