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

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

 



On Tue, Feb 23 2016 at 06:57:28 AM, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>> +/* 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;
> }

There are no divisions in the code segment above. We discussed it
internally and there is agreement to leave the patch as is.
--
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