]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: fec: do not allow enabling PPS and PEROUT simultaneously
authorWei Fang <wei.fang@nxp.com>
Tue, 25 Nov 2025 08:52:09 +0000 (16:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:24:56 +0000 (06:24 +0900)
[ Upstream commit c0a1f3d7e128e8d1b6c0fe09c68eac5ebcf677c8 ]

In the current driver, PPS and PEROUT use the same channel to generate
the events, so they cannot be enabled at the same time. Otherwise, the
later configuration will overwrite the earlier configuration. Therefore,
when configuring PPS, the driver will check whether PEROUT is enabled.
Similarly, when configuring PEROUT, the driver will check whether PPS
is enabled.

Fixes: 350749b909bf ("net: fec: Add support for periodic output signal of PPS")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20251125085210.1094306-4-wei.fang@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/freescale/fec_ptp.c

index a3853fccdc7b62b02a5ba0fb9bbb4440ed9bf630..beb1d98fa741a17de794aa3301db0c4d409feb28 100644 (file)
@@ -129,6 +129,12 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
 
        spin_lock_irqsave(&fep->tmreg_lock, flags);
 
+       if (fep->perout_enable) {
+               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
+               dev_err(&fep->pdev->dev, "PEROUT is running");
+               return -EBUSY;
+       }
+
        if (fep->pps_enable == enable) {
                spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                return 0;
@@ -572,6 +578,12 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
                        }
                        spin_lock_irqsave(&fep->tmreg_lock, flags);
 
+                       if (fep->pps_enable) {
+                               dev_err(&fep->pdev->dev, "PPS is running");
+                               ret = -EBUSY;
+                               goto unlock;
+                       }
+
                        if (fep->perout_enable) {
                                dev_err(&fep->pdev->dev,
                                        "PEROUT has been enabled\n");