All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jiri@mellanox.com, petrm@mellanox.com,
	mlxsw@mellanox.com, Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 11/16] mlxsw: spectrum: PTP: Disable BH when working with PHC
Date: Thu, 27 Jun 2019 16:52:54 +0300	[thread overview]
Message-ID: <20190627135259.7292-12-idosch@idosch.org> (raw)
In-Reply-To: <20190627135259.7292-1-idosch@idosch.org>

From: Petr Machata <petrm@mellanox.com>

Up until now, the PTP hardware clock code was only invoked in the process
context (SYS_clock_adjtime -> do_clock_adjtime -> k_clock::clock_adj ->
pc_clock_adjtime -> posix_clock_operations::clock_adjtime ->
ptp_clock_info::adjtime -> mlxsw_spectrum).

In order to enable HW timestamping, which is tied into trap handling, it
will be necessary to take the clock lock from the PCI queue handler
tasklets as well.

Therefore use the _bh variants when handling the clock lock. Incidentally,
Documentation/ptp/ptp.txt recommends _irqsave variants, but that's
unnecessarily strong for our needs.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../ethernet/mellanox/mlxsw/spectrum_ptp.c    | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
index 6725a4d53f87..1eb6eefa1afc 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
@@ -117,9 +117,9 @@ mlxsw_sp1_ptp_phc_settime(struct mlxsw_sp_ptp_clock *clock, u64 nsec)
 	next_sec = div_u64(nsec, NSEC_PER_SEC) + 1;
 	next_sec_in_nsec = next_sec * NSEC_PER_SEC;
 
-	spin_lock(&clock->lock);
+	spin_lock_bh(&clock->lock);
 	cycles = mlxsw_sp1_ptp_ns2cycles(&clock->tc, next_sec_in_nsec);
-	spin_unlock(&clock->lock);
+	spin_unlock_bh(&clock->lock);
 
 	mlxsw_reg_mtpps_vpin_pack(mtpps_pl, cycles);
 	err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mtpps), mtpps_pl);
@@ -152,11 +152,11 @@ static int mlxsw_sp1_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
 	adj *= ppb;
 	diff = div_u64(adj, NSEC_PER_SEC);
 
-	spin_lock(&clock->lock);
+	spin_lock_bh(&clock->lock);
 	timecounter_read(&clock->tc);
 	clock->cycles.mult = neg_adj ? clock->nominal_c_mult - diff :
 				       clock->nominal_c_mult + diff;
-	spin_unlock(&clock->lock);
+	spin_unlock_bh(&clock->lock);
 
 	return mlxsw_sp1_ptp_phc_adjfreq(clock, neg_adj ? -ppb : ppb);
 }
@@ -167,10 +167,10 @@ static int mlxsw_sp1_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 		container_of(ptp, struct mlxsw_sp_ptp_clock, ptp_info);
 	u64 nsec;
 
-	spin_lock(&clock->lock);
+	spin_lock_bh(&clock->lock);
 	timecounter_adjtime(&clock->tc, delta);
 	nsec = timecounter_read(&clock->tc);
-	spin_unlock(&clock->lock);
+	spin_unlock_bh(&clock->lock);
 
 	return mlxsw_sp1_ptp_phc_settime(clock, nsec);
 }
@@ -183,10 +183,10 @@ static int mlxsw_sp1_ptp_gettimex(struct ptp_clock_info *ptp,
 		container_of(ptp, struct mlxsw_sp_ptp_clock, ptp_info);
 	u64 cycles, nsec;
 
-	spin_lock(&clock->lock);
+	spin_lock_bh(&clock->lock);
 	cycles = __mlxsw_sp1_ptp_read_frc(clock, sts);
 	nsec = timecounter_cyc2time(&clock->tc, cycles);
-	spin_unlock(&clock->lock);
+	spin_unlock_bh(&clock->lock);
 
 	*ts = ns_to_timespec64(nsec);
 
@@ -200,10 +200,10 @@ static int mlxsw_sp1_ptp_settime(struct ptp_clock_info *ptp,
 		container_of(ptp, struct mlxsw_sp_ptp_clock, ptp_info);
 	u64 nsec = timespec64_to_ns(ts);
 
-	spin_lock(&clock->lock);
+	spin_lock_bh(&clock->lock);
 	timecounter_init(&clock->tc, &clock->cycles, nsec);
 	nsec = timecounter_read(&clock->tc);
-	spin_unlock(&clock->lock);
+	spin_unlock_bh(&clock->lock);
 
 	return mlxsw_sp1_ptp_phc_settime(clock, nsec);
 }
@@ -225,9 +225,9 @@ static void mlxsw_sp1_ptp_clock_overflow(struct work_struct *work)
 
 	clock = container_of(dwork, struct mlxsw_sp_ptp_clock, overflow_work);
 
-	spin_lock(&clock->lock);
+	spin_lock_bh(&clock->lock);
 	timecounter_read(&clock->tc);
-	spin_unlock(&clock->lock);
+	spin_unlock_bh(&clock->lock);
 	mlxsw_core_schedule_dw(&clock->overflow_work, clock->overflow_period);
 }
 
-- 
2.20.1


  parent reply	other threads:[~2019-06-27 13:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27 13:52 [PATCH net-next 00/16] mlxsw: PTP timestamping support Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 01/16] mlxsw: reg: Add Monitoring Time Precision Packet Port Configuration Register Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 02/16] mlxsw: reg: Add Monitoring Precision Time Protocol Trap Register Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 03/16] mlxsw: reg: Add Time Precision Packet Timestamping Reading Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 04/16] mlxsw: reg: Add Monitoring Global Configuration Register Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 05/16] mlxsw: spectrum: Extract a helper for trap registration Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 06/16] mlxsw: spectrum: Add support for traps specific to Spectrum-1 Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 07/16] mlxsw: spectrum: PTP: Hook into packet receive path Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 08/16] mlxsw: core: Add support for using SKB control buffer Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 09/16] mlxsw: pci: PTP: Hook into packet transmit path Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 10/16] mlxsw: spectrum: PTP: Add PTP initialization / finalization Ido Schimmel
2019-06-27 13:52 ` Ido Schimmel [this message]
2019-06-27 13:52 ` [PATCH net-next 12/16] mlxsw: spectrum: PTP: Support timestamping on Spectrum-1 Ido Schimmel
2019-06-27 17:04   ` David Miller
2019-06-27 17:57     ` Petr Machata
2019-06-27 13:52 ` [PATCH net-next 13/16] mlxsw: spectrum: PTP: Garbage-collect unmatched entries Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 14/16] mlxsw: spectrum: PTP: Configure PTP traps and FIFO events Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 15/16] mlxsw: spectrum: PTP: Support SIOCGHWTSTAMP, SIOCSHWTSTAMP ioctls Ido Schimmel
2019-06-27 13:52 ` [PATCH net-next 16/16] mlxsw: spectrum: PTP: Support ethtool get_ts_info Ido Schimmel
2019-06-27 16:51 ` [PATCH net-next 00/16] mlxsw: PTP timestamping support Richard Cochran
2019-06-27 17:35   ` Ido Schimmel
2019-06-27 17:46     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190627135259.7292-12-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.