xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Tim Deegan <tim@xen.org>
Cc: george.dunlap@eu.citrix.com, roger.pau@citrix.com, keir@xen.org,
	JBeulich@suse.com, Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH RFC v2 1/3] x86/hvm/rtc: Don't run the vpt timer when !REG_B.PIE.
Date: Sat, 15 Feb 2014 00:02:15 +0000	[thread overview]
Message-ID: <52FEAE87.9070601@citrix.com> (raw)
In-Reply-To: <20140214230312.GA33715@deinos.phlegethon.org>

On 14/02/2014 23:03, Tim Deegan wrote:
> At 19:51 +0000 on 14 Feb (1392403919), Andrew Cooper wrote:
>> From: Tim Deegan <tim@xen.org>
>>
>> If the guest has not asked for interrupts, don't run the vpt timer
>> to generate them.  This is a prerequisite for a patch to simplify how
>> the vpt interacts with the RTC, and also gets rid of a timer series in
>> Xen in a case where it's unlikely to be needed.
>>
>> Instead, calculate the correct value for REG_C.PF whenever REG_C is
>> read or PIE is enabled.  This allow a guest to poll for the PF bit
>> while not asking for actual timer interrupts.  Such a guest would no
>> longer get the benefit of the vpt's timer modes.
>>
>> Signed-off-by: Tim Deegan <tim@xen.org>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>
>> ---
>>
>> Changes in v2:
>>  * Reduce scope of `now` in rtc_timer_update()
>>  * Merge PIE logic in REG_B write
>>  * Tightly couple setting s->period with creating/destroying timers, so the
>>    timer change gets properly recreated when the guest sets REG_B.PIE
> Thanks for sorting out that bug, but I think in this version the !PIE
> case won't work.  check_for_pf_ticks() uses s->period to figure out
> whether to set PF, so it needs to be set whenever the REG_A selector
> is configured, even if the timer's not running.
>
> It looks like always setting s->period == 0 just before the call to
> rtc_timer_update in the REG_B write (i.e. not just in the !PIE case)
> would DTRT, but is that what you tried earlier?

I tried the "careful clobbering" which resulted in the fragment below,
and altering the position of s->period in rtc_timer_update() to match,
but that does indeed lead to issues of s->period being 0 if !PIE.

I clearly should have been less careful.

>
> Er, that is, here:
>
>>          rtc_update_irq(s);
>> -        if ( (data & RTC_PIE) && !(orig & RTC_PIE) )
>> +        if ( (data ^ orig) & RTC_PIE )
>> +        {
>> +            if ( !(data & RTC_PIE) )
>> +            {
>> +                destroy_periodic_time(&s->pt);
>> +                s->period = 0;
>> +            }
>>              rtc_timer_update(s);
>> +        }
>>          if ( (data ^ orig) & RTC_SET )
> do this:
>
>> +        if ( (data ^ orig) & RTC_PIE )
>> +        {
>> +            destroy_periodic_time(&s->pt);
>> +            s->period = 0;
>>              rtc_timer_update(s);
>> +        }
> Tim.

... and undo the changes in rtc_timer_update().

~Andrew

  reply	other threads:[~2014-02-15  0:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14 19:51 [PATCH RFC v2 0/3] Move RTC interrupt injection back into the vpt code Andrew Cooper
2014-02-14 19:51 ` [PATCH RFC v2 1/3] x86/hvm/rtc: Don't run the vpt timer when !REG_B.PIE Andrew Cooper
2014-02-14 23:03   ` Tim Deegan
2014-02-15  0:02     ` Andrew Cooper [this message]
2014-02-14 19:52 ` [PATCH RFC v2 2/3] x86/hvm/rtc: Inject RTC periodic interupts from the vpt code Andrew Cooper
2014-02-14 19:52 ` [PATCH RFC v2 3/3] x86/hvm/rtc: Always deassert the IRQ line when clearing REG_C.IRQF Andrew Cooper

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=52FEAE87.9070601@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).