Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp169544rdg; Thu, 12 Oct 2023 02:03:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwpTqosWaG2TVmzkx06DT4uZjDD+d1qngSkxVURRN7GlpcqNv2ZPsWcCLHLPFP+xp6G9Wf X-Received: by 2002:a17:90b:8e:b0:27c:fc2a:a178 with SMTP id bb14-20020a17090b008e00b0027cfc2aa178mr5549172pjb.9.1697101385374; Thu, 12 Oct 2023 02:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697101385; cv=none; d=google.com; s=arc-20160816; b=aDFI9A4RCrAtnD5l4LOISpILd+ibemSUGjmBV9z6RnHAX1tknhfXLVLEl70PwPFrtI J99IkzYUQMgdsVnpjQElUKCWqhQp+fegXPRYmNOW6OHPh84X0Gns/cP5IamaK+eibk/z 1w8EVoMCr1PkimJxM/BUi8GrY67RnFtoKoVrih26AjhB0qLK50cjEUziricXV5VZVtnK fc5asc21fcKOa/vjvSc1MvO5+R2Se5M/2U1vu2011OFMZA7mKNAY0JKoxmpEgsFejRcj 0NE2Sikv1sQ7VGZMQPtuCRtUh/6EtX5erQTRhj2U/nx9A9yHO3cnDeSnCnZGgemDeAVe iynQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=HQB+B7AebL+YrbcjIuUs7q7Pf8wEw1DvuNZ3EMH8Lhc=; fh=mcO6uPWa+EaE31BIxnnEPPB7Uowy5Tf+alts1RnogN0=; b=l1ZYdIWopw5A7cEcT5Gatsa52aptviYGtIn4QNLJCfHam6+1CWDwE1vt8r/xRgeyrO KwJvhSppIyQcqD7u/5WvAQiFIZ5IrD4gPqQPq/QH2HIlhd8nqRi0zYRIgyzMiZDQCd2A VjFShoCjuh+xrto6lg9Z6GE/DT0VsB892Y6Zwj0+k0QVdJOC9RTew7I/LvBMlJNCXACF 3cHYiFl+d6Lo7pzdLyq2bRyYROGwT29UNWPJZ1Jbh/YG+zJIaISFlIwpFmxnhmfwuJ++ AVJIypQUebWWysQcDGxI3JjDgK79m39DnxEdCBvxvEAGnemoG8KpbhB4xYoi+JCYSXFk czeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id v7-20020a17090ac90700b00279020d1fb0si1802395pjt.129.2023.10.12.02.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 02:03:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5E0D48171691; Thu, 12 Oct 2023 02:03:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235360AbjJLJCr (ORCPT + 99 others); Thu, 12 Oct 2023 05:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235511AbjJLJCl (ORCPT ); Thu, 12 Oct 2023 05:02:41 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5CEA9 for ; Thu, 12 Oct 2023 02:02:37 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qqraM-0000CL-Lt; Thu, 12 Oct 2023 11:02:26 +0200 Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqraL-0016dN-0h; Thu, 12 Oct 2023 11:02:25 +0200 Received: from localhost ([::1] helo=dude03.red.stw.pengutronix.de) by dude03.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1qqral-00FyMl-1P; Thu, 12 Oct 2023 11:02:24 +0200 From: Johannes Zink Date: Thu, 12 Oct 2023 11:02:16 +0200 Subject: [PATCH net-next 5/5] net: stmmac: do not silently change auxiliary snapshot capture channel MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231010-stmmac_fix_auxiliary_event_capture-v1-5-3eeca9e844fa@pengutronix.de> References: <20231010-stmmac_fix_auxiliary_event_capture-v1-0-3eeca9e844fa@pengutronix.de> In-Reply-To: <20231010-stmmac_fix_auxiliary_event_capture-v1-0-3eeca9e844fa@pengutronix.de> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Kurt Kanzenbach Cc: patchwork-jzi@pengutronix.de, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Johannes Zink X-Mailer: b4 0.12.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: j.zink@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 12 Oct 2023 02:03:00 -0700 (PDT) Even though the hardware theoretically supports up to 4 simultaneous auxiliary snapshot capture channels, the stmmac driver does support only a single channel to be active at a time. Previously in case of a PTP_CLK_REQ_EXTTS request, previously active auxiliary snapshot capture channels were silently dropped and the new channel was activated. Instead of silently changing the state for all consumers, log an error and return -EBUSY if a channel is already in use in order to signal to userspace to disable the currently active channel before enabling another one. Signed-off-by: Johannes Zink --- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index 2a141db70c2e..56683afc650c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -191,11 +191,23 @@ static int stmmac_enable(struct ptp_clock_info *ptp, priv->systime_flags); write_unlock_irqrestore(&priv->ptp_lock, flags); break; - case PTP_CLK_REQ_EXTTS: + case PTP_CLK_REQ_EXTTS: { + u8 channel; + mutex_lock(&priv->aux_ts_lock); acr_value = readl(ptpaddr + PTP_ACR); + channel = ilog2(FIELD_GET(PTP_ACR_MASK, acr_value)); acr_value &= ~PTP_ACR_MASK; + if (on) { + if (FIELD_GET(PTP_ACR_MASK, acr_value)) { + netdev_err(priv->dev, + "Cannot enable auxiliary snapshot %d as auxiliary snapshot %d is already enabled", + rq->extts.index, channel); + mutex_unlock(&priv->aux_ts_lock); + return -EBUSY; + } + priv->plat->flags |= STMMAC_FLAG_EXT_SNAPSHOT_EN; /* Enable External snapshot trigger */ @@ -213,6 +225,7 @@ static int stmmac_enable(struct ptp_clock_info *ptp, !(acr_value & PTP_ACR_ATSFC), 10, 10000); break; + } default: break; -- 2.39.2