Re: [PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
From: Nicolas PitreDate: Tue, 20 Sep 2016 19:25:58 -0400 (EDT) > > Drivers must be ready to accept NULL from ptp_clock_register() if the > PTP clock subsystem is configured out. > > This patch documents that and ensures that all drivers cope well > with a NULL return. > > Signed-off-by: Nicolas Pitre > Reviewed-by: Eugenia Emantayev > > --- > > Let's have the basics merged now and work out the actual Kconfig issue > separately. Richard, if you agree with this patch, I think this could go > via the netdev tree. Applied to net-next, thanks.
Re: [PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
From: Nicolas Pitre Date: Tue, 20 Sep 2016 19:25:58 -0400 (EDT) > > Drivers must be ready to accept NULL from ptp_clock_register() if the > PTP clock subsystem is configured out. > > This patch documents that and ensures that all drivers cope well > with a NULL return. > > Signed-off-by: Nicolas Pitre > Reviewed-by: Eugenia Emantayev > > --- > > Let's have the basics merged now and work out the actual Kconfig issue > separately. Richard, if you agree with this patch, I think this could go > via the netdev tree. Applied to net-next, thanks.
Re: [PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
On 21/09/16 00:25, Nicolas Pitre wrote: > Drivers must be ready to accept NULL from ptp_clock_register() if the > PTP clock subsystem is configured out. > > This patch documents that and ensures that all drivers cope well > with a NULL return. > > Signed-off-by: Nicolas Pitre> Reviewed-by: Eugenia Emantayev [...] > diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c > index c771e0af4e..f105a170b4 100644 > --- a/drivers/net/ethernet/sfc/ptp.c > +++ b/drivers/net/ethernet/sfc/ptp.c > @@ -1269,13 +1269,13 @@ int efx_ptp_probe(struct efx_nic *efx, struct > efx_channel *channel) > if (IS_ERR(ptp->phc_clock)) { > rc = PTR_ERR(ptp->phc_clock); > goto fail3; > - } > - > - INIT_WORK(>pps_work, efx_ptp_pps_worker); > - ptp->pps_workwq = create_singlethread_workqueue("sfc_pps"); > - if (!ptp->pps_workwq) { > - rc = -ENOMEM; > - goto fail4; > + } else if (ptp->phc_clock) { > + INIT_WORK(>pps_work, efx_ptp_pps_worker); > + ptp->pps_workwq = > create_singlethread_workqueue("sfc_pps"); > + if (!ptp->pps_workwq) { > + rc = -ENOMEM; > + goto fail4; > + } > } > } > ptp->nic_ts_enabled = false; For the sfc change: Acked-by: Edward Cree
Re: [PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
On 21/09/16 00:25, Nicolas Pitre wrote: > Drivers must be ready to accept NULL from ptp_clock_register() if the > PTP clock subsystem is configured out. > > This patch documents that and ensures that all drivers cope well > with a NULL return. > > Signed-off-by: Nicolas Pitre > Reviewed-by: Eugenia Emantayev [...] > diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c > index c771e0af4e..f105a170b4 100644 > --- a/drivers/net/ethernet/sfc/ptp.c > +++ b/drivers/net/ethernet/sfc/ptp.c > @@ -1269,13 +1269,13 @@ int efx_ptp_probe(struct efx_nic *efx, struct > efx_channel *channel) > if (IS_ERR(ptp->phc_clock)) { > rc = PTR_ERR(ptp->phc_clock); > goto fail3; > - } > - > - INIT_WORK(>pps_work, efx_ptp_pps_worker); > - ptp->pps_workwq = create_singlethread_workqueue("sfc_pps"); > - if (!ptp->pps_workwq) { > - rc = -ENOMEM; > - goto fail4; > + } else if (ptp->phc_clock) { > + INIT_WORK(>pps_work, efx_ptp_pps_worker); > + ptp->pps_workwq = > create_singlethread_workqueue("sfc_pps"); > + if (!ptp->pps_workwq) { > + rc = -ENOMEM; > + goto fail4; > + } > } > } > ptp->nic_ts_enabled = false; For the sfc change: Acked-by: Edward Cree
Re: [PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
On Tue, Sep 20, 2016 at 07:25:58PM -0400, Nicolas Pitre wrote: > > Drivers must be ready to accept NULL from ptp_clock_register() if the > PTP clock subsystem is configured out. > > This patch documents that and ensures that all drivers cope well > with a NULL return. > > Signed-off-by: Nicolas Pitre> Reviewed-by: Eugenia Emantayev > > --- > > Let's have the basics merged now and work out the actual Kconfig issue > separately. Richard, if you agree with this patch, I think this could go > via the netdev tree. It looks ok to me. Acked-by: Richard Cochran
Re: [PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
On Tue, Sep 20, 2016 at 07:25:58PM -0400, Nicolas Pitre wrote: > > Drivers must be ready to accept NULL from ptp_clock_register() if the > PTP clock subsystem is configured out. > > This patch documents that and ensures that all drivers cope well > with a NULL return. > > Signed-off-by: Nicolas Pitre > Reviewed-by: Eugenia Emantayev > > --- > > Let's have the basics merged now and work out the actual Kconfig issue > separately. Richard, if you agree with this patch, I think this could go > via the netdev tree. It looks ok to me. Acked-by: Richard Cochran
[PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
Drivers must be ready to accept NULL from ptp_clock_register() if the PTP clock subsystem is configured out. This patch documents that and ensures that all drivers cope well with a NULL return. Signed-off-by: Nicolas PitreReviewed-by: Eugenia Emantayev --- Let's have the basics merged now and work out the actual Kconfig issue separately. Richard, if you agree with this patch, I think this could go via the netdev tree. diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c index 2e1b17ad52..ad03763e00 100644 --- a/drivers/net/ethernet/intel/e1000e/ptp.c +++ b/drivers/net/ethernet/intel/e1000e/ptp.c @@ -334,7 +334,7 @@ void e1000e_ptp_init(struct e1000_adapter *adapter) if (IS_ERR(adapter->ptp_clock)) { adapter->ptp_clock = NULL; e_err("ptp_clock_register failed\n"); - } else { + } else if (adapter->ptp_clock) { e_info("registered PHC clock\n"); } } diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index ed39cbad24..f1feceab75 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c @@ -669,7 +669,7 @@ void i40e_ptp_init(struct i40e_pf *pf) pf->ptp_clock = NULL; dev_err(>pdev->dev, "%s: ptp_clock_register failed\n", __func__); - } else { + } else if (pf->ptp_clock) { struct timespec64 ts; u32 regval; diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 336c103ae3..7531892b08 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -1159,7 +1159,7 @@ void igb_ptp_init(struct igb_adapter *adapter) if (IS_ERR(adapter->ptp_clock)) { adapter->ptp_clock = NULL; dev_err(>pdev->dev, "ptp_clock_register failed\n"); - } else { + } else if (adapter->ptp_clock) { dev_info(>pdev->dev, "added PHC on %s\n", adapter->netdev->name); adapter->ptp_flags |= IGB_PTP_ENABLED; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c index e5431bfe33..a92277683a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c @@ -1254,7 +1254,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) adapter->ptp_clock = NULL; e_dev_err("ptp_clock_register failed\n"); return err; - } else + } else if (adapter->ptp_clock) e_dev_info("registered PHC device on %s\n", netdev->name); /* set default timestamp mode to disabled here. We do this in diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c index 1494997c4f..08fc5fc56d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c @@ -298,7 +298,7 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev) if (IS_ERR(mdev->ptp_clock)) { mdev->ptp_clock = NULL; mlx4_err(mdev, "ptp_clock_register failed\n"); - } else { + } else if (mdev->ptp_clock) { mlx4_info(mdev, "registered PHC clock\n"); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c index 847a8f3ac2..13dc388667 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c @@ -273,7 +273,7 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv) tstamp->ptp = ptp_clock_register(>ptp_info, >mdev->pdev->dev); - if (IS_ERR_OR_NULL(tstamp->ptp)) { + if (IS_ERR(tstamp->ptp)) { mlx5_core_warn(priv->mdev, "ptp_clock_register failed %ld\n", PTR_ERR(tstamp->ptp)); tstamp->ptp = NULL; diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index c771e0af4e..f105a170b4 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c @@ -1269,13 +1269,13 @@ int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel) if (IS_ERR(ptp->phc_clock)) { rc = PTR_ERR(ptp->phc_clock); goto fail3; - } - - INIT_WORK(>pps_work, efx_ptp_pps_worker); - ptp->pps_workwq = create_singlethread_workqueue("sfc_pps"); - if (!ptp->pps_workwq) { - rc = -ENOMEM; - goto fail4; + } else if (ptp->phc_clock) { + INIT_WORK(>pps_work,
[PATCH] ptp_clock: future-proofing drivers against PTP subsystem becoming optional
Drivers must be ready to accept NULL from ptp_clock_register() if the PTP clock subsystem is configured out. This patch documents that and ensures that all drivers cope well with a NULL return. Signed-off-by: Nicolas Pitre Reviewed-by: Eugenia Emantayev --- Let's have the basics merged now and work out the actual Kconfig issue separately. Richard, if you agree with this patch, I think this could go via the netdev tree. diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c index 2e1b17ad52..ad03763e00 100644 --- a/drivers/net/ethernet/intel/e1000e/ptp.c +++ b/drivers/net/ethernet/intel/e1000e/ptp.c @@ -334,7 +334,7 @@ void e1000e_ptp_init(struct e1000_adapter *adapter) if (IS_ERR(adapter->ptp_clock)) { adapter->ptp_clock = NULL; e_err("ptp_clock_register failed\n"); - } else { + } else if (adapter->ptp_clock) { e_info("registered PHC clock\n"); } } diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index ed39cbad24..f1feceab75 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c @@ -669,7 +669,7 @@ void i40e_ptp_init(struct i40e_pf *pf) pf->ptp_clock = NULL; dev_err(>pdev->dev, "%s: ptp_clock_register failed\n", __func__); - } else { + } else if (pf->ptp_clock) { struct timespec64 ts; u32 regval; diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 336c103ae3..7531892b08 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -1159,7 +1159,7 @@ void igb_ptp_init(struct igb_adapter *adapter) if (IS_ERR(adapter->ptp_clock)) { adapter->ptp_clock = NULL; dev_err(>pdev->dev, "ptp_clock_register failed\n"); - } else { + } else if (adapter->ptp_clock) { dev_info(>pdev->dev, "added PHC on %s\n", adapter->netdev->name); adapter->ptp_flags |= IGB_PTP_ENABLED; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c index e5431bfe33..a92277683a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c @@ -1254,7 +1254,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) adapter->ptp_clock = NULL; e_dev_err("ptp_clock_register failed\n"); return err; - } else + } else if (adapter->ptp_clock) e_dev_info("registered PHC device on %s\n", netdev->name); /* set default timestamp mode to disabled here. We do this in diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c index 1494997c4f..08fc5fc56d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c @@ -298,7 +298,7 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev) if (IS_ERR(mdev->ptp_clock)) { mdev->ptp_clock = NULL; mlx4_err(mdev, "ptp_clock_register failed\n"); - } else { + } else if (mdev->ptp_clock) { mlx4_info(mdev, "registered PHC clock\n"); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c index 847a8f3ac2..13dc388667 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_clock.c @@ -273,7 +273,7 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv) tstamp->ptp = ptp_clock_register(>ptp_info, >mdev->pdev->dev); - if (IS_ERR_OR_NULL(tstamp->ptp)) { + if (IS_ERR(tstamp->ptp)) { mlx5_core_warn(priv->mdev, "ptp_clock_register failed %ld\n", PTR_ERR(tstamp->ptp)); tstamp->ptp = NULL; diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index c771e0af4e..f105a170b4 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c @@ -1269,13 +1269,13 @@ int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel) if (IS_ERR(ptp->phc_clock)) { rc = PTR_ERR(ptp->phc_clock); goto fail3; - } - - INIT_WORK(>pps_work, efx_ptp_pps_worker); - ptp->pps_workwq = create_singlethread_workqueue("sfc_pps"); - if (!ptp->pps_workwq) { - rc = -ENOMEM; - goto fail4; + } else if (ptp->phc_clock) { + INIT_WORK(>pps_work, efx_ptp_pps_worker); +