Re: staging/rdma/hfi1: Add support for enabling/disabling PCIe ASPM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +/* ASPM processing for each receive context interrupt */
> +static inline void aspm_ctx_disable(struct hfi1_ctxtdata *rcd)
> +{
> +	bool restart_timer;
> +	bool close_interrupts;
> +	unsigned long flags;
> +	ktime_t now, prev;
> +
> +	/* Quickest exit for minimum impact */
> +	if (!rcd->aspm_intr_supported)
> +		return;
> +
> +	spin_lock_irqsave(&rcd->aspm_lock, flags);
> +	/* PSM contexts are open */
> +	if (!rcd->aspm_intr_enable)
> +		goto ret;
> +
> +	prev = rcd->aspm_ts_last_intr;
> +	now = ktime_get();
> +	rcd->aspm_ts_last_intr = now;
> +
> +	/* An interrupt pair close together in time */
> +	close_interrupts = ktime_to_ns(ktime_sub(now, prev)) <
> ASPM_TRIGGER_NS;
> +
> +	/* Don't push out our timer till this much time has elapsed
> */
> +	restart_timer = ktime_to_ms(ktime_sub(now, rcd-
> >aspm_ts_timer_sched)) >
> +				ASPM_RESCHED_TIMER_MS;

> +	restart_timer = restart_timer && close_interrupts;
> +
> +	/* Disable ASPM and schedule timer */
> +	if (rcd->aspm_enabled && close_interrupts) {
> +		aspm_disable_inc(rcd->dd);
> +		rcd->aspm_enabled = false;
> +		restart_timer = true;
> +	}
> +
> +	if (restart_timer) {
> +		mod_timer(&rcd->aspm_timer,
> +			  jiffies +
> msecs_to_jiffies(ASPM_TIMER_MS));
> +		rcd->aspm_ts_timer_sched = now;
> +	}

What about the following changes (mostly about replacing divisions by
multiplications)?


ktime_t eta, restart;

eta = ktime_add_ns(rcd->aspm_ts_last_intr, ASPM_TRIGGER_NS);

rcd->aspm_ts_last_intr = ktime_get();

/* Close interrupts? */
if (ktime_before(now, eta)) {
  /* Disable ASPM? */
  if (rcd->aspm_enabled) {
   
aspm_disable_inc(rcd->dd);
    rcd->aspm_enabled = false;
  } else {
   
restart = ktime_add_ms(rcd->aspm_ts_timer_sched,
ASPM_RESCHED_TIMER_MS);
    if (ktime_before(rcd->aspm_ts_last_intr,
restart))
      goto exit_unlock;
  }

  /* Restart timer */
  mod_timer(&rcd->aspm_timer, jiffies + msecs_to_jiffies(ASPM_TIMER_MS));
  rcd->aspm_ts_timer_sched = rcd->aspm_ts_last_intr;
}

> +ret:

Better naming is 'exit_unlock' or just 'unlock'.

> +	spin_unlock_irqrestore(&rcd->aspm_lock, flags);
> +}


-- 
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux