diff mbox series

[3/3] phy: nxp-c45-tja11xx: read the tx timestamp without lock

Message ID 20211220120859.140453-3-radu-nicolae.pirea@oss.nxp.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/3] ptp: add PTP_PEROUT_REVERSE_POLARITY flag | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter warning Series does not have a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Radu Pirea (NXP OSS) Dec. 20, 2021, 12:08 p.m. UTC
The tx timestamps are read from only one place in interrupt or polling
mode. Locking the mutex is useless.

Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
---
 drivers/net/phy/nxp-c45-tja11xx.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Andrew Lunn Dec. 20, 2021, 3:10 p.m. UTC | #1
On Mon, Dec 20, 2021 at 02:08:59PM +0200, Radu Pirea (NXP OSS) wrote:
> The tx timestamps are read from only one place in interrupt or polling
> mode. Locking the mutex is useless.

You cannot take a mutex in an interrupt handler. So your description
is probably not accurate.

Is it safe for other ptp operations to be performed in parallel with
reading the TX timestamp? _nxp_c45_ptp_settime64()?

	Andrew
Radu Pirea (NXP OSS) Dec. 22, 2021, 8:19 a.m. UTC | #2
On Mon, 2021-12-20 at 16:10 +0100, Andrew Lunn wrote:
> On Mon, Dec 20, 2021 at 02:08:59PM +0200, Radu Pirea (NXP OSS) wrote:
> > The tx timestamps are read from only one place in interrupt or
> > polling
> > mode. Locking the mutex is useless.
> 
> You cannot take a mutex in an interrupt handler. So your description
> is probably not accurate.
Actually this is the second issue.
I will improve the description.
> 
> Is it safe for other ptp operations to be performed in parallel with
> reading the TX timestamp? _nxp_c45_ptp_settime64()?
Yes, it's safe. The purpose of the mutex is to protect the access to
LTC(PTP counter).
> 
>         Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
index 74de66c90f24..5bd8c166d726 100644
--- a/drivers/net/phy/nxp-c45-tja11xx.c
+++ b/drivers/net/phy/nxp-c45-tja11xx.c
@@ -381,7 +381,6 @@  static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv,
 	bool valid;
 	u16 reg;
 
-	mutex_lock(&priv->ptp_lock);
 	phy_write_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_CTRL,
 		      RING_DONE);
 	reg = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1, VEND1_EGR_RING_DATA_0);
@@ -401,8 +400,6 @@  static bool nxp_c45_get_hwtxts(struct nxp_c45_phy *priv,
 	hwts->sec |= (reg & RING_DATA_3_SEC_1_0) >> 14;
 
 nxp_c45_get_hwtxts_out:
-	mutex_unlock(&priv->ptp_lock);
-
 	return valid;
 }