Unverified Commit b3d87b11 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12178 net: stmmac: move the EST lock to struct stmmac_priv

parents e36173be 187fd018
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -248,6 +248,8 @@ struct stmmac_priv {
	struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
	struct stmmac_safety_stats sstats;
	struct plat_stmmacenet_data *plat;
	/* Protect est parameters */
	struct mutex est_lock;
	struct dma_features dma_cap;
	struct stmmac_counters mmc;
	int hw_cap_support;
+4 −4
Original line number Diff line number Diff line
@@ -70,11 +70,11 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
	/* If EST is enabled, disabled it before adjust ptp time. */
	if (priv->plat->est && priv->plat->est->enable) {
		est_rst = true;
		mutex_lock(&priv->plat->est->lock);
		mutex_lock(&priv->est_lock);
		priv->plat->est->enable = false;
		stmmac_est_configure(priv, priv->ioaddr, priv->plat->est,
				     priv->plat->clk_ptp_rate);
		mutex_unlock(&priv->plat->est->lock);
		mutex_unlock(&priv->est_lock);
	}

	write_lock_irqsave(&priv->ptp_lock, flags);
@@ -87,7 +87,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
		ktime_t current_time_ns, basetime;
		u64 cycle_time;

		mutex_lock(&priv->plat->est->lock);
		mutex_lock(&priv->est_lock);
		priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, &current_time);
		current_time_ns = timespec64_to_ktime(current_time);
		time.tv_nsec = priv->plat->est->btr_reserve[0];
@@ -104,7 +104,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
		priv->plat->est->enable = true;
		ret = stmmac_est_configure(priv, priv->ioaddr, priv->plat->est,
					   priv->plat->clk_ptp_rate);
		mutex_unlock(&priv->plat->est->lock);
		mutex_unlock(&priv->est_lock);
		if (ret)
			netdev_err(priv->dev, "failed to configure EST\n");
	}
+10 −8
Original line number Diff line number Diff line
@@ -983,17 +983,19 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
		if (!plat->est)
			return -ENOMEM;

		mutex_init(&priv->plat->est->lock);
		mutex_init(&priv->est_lock);
	} else {
		mutex_lock(&priv->est_lock);
		memset(plat->est, 0, sizeof(*plat->est));
		mutex_unlock(&priv->est_lock);
	}

	size = qopt->num_entries;

	mutex_lock(&priv->plat->est->lock);
	mutex_lock(&priv->est_lock);
	priv->plat->est->gcl_size = size;
	priv->plat->est->enable = qopt->cmd == TAPRIO_CMD_REPLACE;
	mutex_unlock(&priv->plat->est->lock);
	mutex_unlock(&priv->est_lock);

	for (i = 0; i < size; i++) {
		s64 delta_ns = qopt->entries[i].interval;
@@ -1024,7 +1026,7 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
		priv->plat->est->gcl[i] = delta_ns | (gates << wid);
	}

	mutex_lock(&priv->plat->est->lock);
	mutex_lock(&priv->est_lock);
	/* Adjust for real system time */
	priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, &current_time);
	current_time_ns = timespec64_to_ktime(current_time);
@@ -1043,7 +1045,7 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
	priv->plat->est->ctr[1] = (u32)ctr;

	if (fpe && !priv->dma_cap.fpesel) {
		mutex_unlock(&priv->plat->est->lock);
		mutex_unlock(&priv->est_lock);
		return -EOPNOTSUPP;
	}

@@ -1054,7 +1056,7 @@ static int tc_setup_taprio(struct stmmac_priv *priv,

	ret = stmmac_est_configure(priv, priv->ioaddr, priv->plat->est,
				   priv->plat->clk_ptp_rate);
	mutex_unlock(&priv->plat->est->lock);
	mutex_unlock(&priv->est_lock);
	if (ret) {
		netdev_err(priv->dev, "failed to configure EST\n");
		goto disable;
@@ -1071,11 +1073,11 @@ static int tc_setup_taprio(struct stmmac_priv *priv,

disable:
	if (priv->plat->est) {
		mutex_lock(&priv->plat->est->lock);
		mutex_lock(&priv->est_lock);
		priv->plat->est->enable = false;
		stmmac_est_configure(priv, priv->ioaddr, priv->plat->est,
				     priv->plat->clk_ptp_rate);
		mutex_unlock(&priv->plat->est->lock);
		mutex_unlock(&priv->est_lock);
	}

	priv->plat->fpe_cfg->enable = false;
+0 −1
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@ struct stmmac_axi {

#define EST_GCL		1024
struct stmmac_est {
	struct mutex lock;
	int enable;
	u32 btr_reserve[2];
	u32 btr_offset[2];