All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/4] ARM: KVM: arch_timers: Add guest timer core support
Date: Tue, 15 Jan 2013 11:07:20 +0000	[thread overview]
Message-ID: <50F53868.4060208@arm.com> (raw)
In-Reply-To: <CANM98qJZH0q-TU942pA363g4h-CENUPiA=b5D0hJyBwrHQ0g7A@mail.gmail.com>

On 14/01/13 19:19, Christoffer Dall wrote:
> On Mon, Jan 14, 2013 at 10:18 AM, Will Deacon <will.deacon@arm.com> wrote:
>> On Tue, Jan 08, 2013 at 06:43:20PM +0000, Christoffer Dall wrote:
>>> From: Marc Zyngier <marc.zyngier@arm.com>
>>>
>>> Add some the architected timer related infrastructure, and support timer
>>> interrupt injection, which can happen as a resultof three possible
>>> events:
>>>
>>> - The virtual timer interrupt has fired while we were still
>>>   executing the guest
>>> - The timer interrupt hasn't fired, but it expired while we
>>>   were doing the world switch
>>> - A hrtimer we programmed earlier has fired
>>
>> [...]
>>
>>> +void kvm_timer_sync_to_cpu(struct kvm_vcpu *vcpu)
>>> +{
>>> +       struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
>>> +
>>> +       /*
>>> +        * We're about to run this vcpu again, so there is no need to
>>> +        * keep the background timer running, as we're about to
>>> +        * populate the CPU timer again.
>>> +        */
>>> +       timer_disarm(timer);
>>> +}
>>> +
>>> +void kvm_timer_sync_from_cpu(struct kvm_vcpu *vcpu)
>>> +{
>>> +       struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
>>> +       cycle_t cval, now;
>>> +       u64 ns;
>>> +
>>> +       /* Check if the timer is enabled and unmasked first */
>>> +       if ((timer->cntv_ctl & 3) != 1)
>>> +               return;
>>> +
>>> +       cval = timer->cntv_cval;
>>> +       now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff;
>>> +
>>> +       BUG_ON(timer_is_armed(timer));
>>> +
>>> +       if (cval <= now) {
>>> +               /*
>>> +                * Timer has already expired while we were not
>>> +                * looking. Inject the interrupt and carry on.
>>> +                */
>>> +               kvm_timer_inject_irq(vcpu);
>>> +               return;
>>> +       }
>>> +
>>> +       ns = cyclecounter_cyc2ns(timecounter->cc, cval - now);
>>> +       timer_arm(timer, ns);
>>> +}
>>
>> Please use flush/sync terminology to match the rest of arch/arm/.
>>
> ok, the following fixes this for both timers and the vgic:
> 
> commit 1b68f39459dbc797f6766c103edf2c1053984161
> Author: Christoffer Dall <c.dall@virtualopensystems.com>
> Date:   Mon Jan 14 14:16:31 2013 -0500
> 
>     KVM: ARM: vgic: use sync/flush terminology
> 
>     Use sync/flush for saving state to/from CPUs to be consistent with
>     other uses in arch/arm.

Sync and flush on their own are pretty inexpressive. Consider changing
it to {flush,sync}_hwstate, so we're consistent with what VFP does.

	M.
-- 
Jazz is not dead. It just smells funny...

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <c.dall@virtualopensystems.com>
Cc: Will Deacon <Will.Deacon@arm.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: [PATCH v5 2/4] ARM: KVM: arch_timers: Add guest timer core support
Date: Tue, 15 Jan 2013 11:07:20 +0000	[thread overview]
Message-ID: <50F53868.4060208@arm.com> (raw)
In-Reply-To: <CANM98qJZH0q-TU942pA363g4h-CENUPiA=b5D0hJyBwrHQ0g7A@mail.gmail.com>

On 14/01/13 19:19, Christoffer Dall wrote:
> On Mon, Jan 14, 2013 at 10:18 AM, Will Deacon <will.deacon@arm.com> wrote:
>> On Tue, Jan 08, 2013 at 06:43:20PM +0000, Christoffer Dall wrote:
>>> From: Marc Zyngier <marc.zyngier@arm.com>
>>>
>>> Add some the architected timer related infrastructure, and support timer
>>> interrupt injection, which can happen as a resultof three possible
>>> events:
>>>
>>> - The virtual timer interrupt has fired while we were still
>>>   executing the guest
>>> - The timer interrupt hasn't fired, but it expired while we
>>>   were doing the world switch
>>> - A hrtimer we programmed earlier has fired
>>
>> [...]
>>
>>> +void kvm_timer_sync_to_cpu(struct kvm_vcpu *vcpu)
>>> +{
>>> +       struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
>>> +
>>> +       /*
>>> +        * We're about to run this vcpu again, so there is no need to
>>> +        * keep the background timer running, as we're about to
>>> +        * populate the CPU timer again.
>>> +        */
>>> +       timer_disarm(timer);
>>> +}
>>> +
>>> +void kvm_timer_sync_from_cpu(struct kvm_vcpu *vcpu)
>>> +{
>>> +       struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
>>> +       cycle_t cval, now;
>>> +       u64 ns;
>>> +
>>> +       /* Check if the timer is enabled and unmasked first */
>>> +       if ((timer->cntv_ctl & 3) != 1)
>>> +               return;
>>> +
>>> +       cval = timer->cntv_cval;
>>> +       now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff;
>>> +
>>> +       BUG_ON(timer_is_armed(timer));
>>> +
>>> +       if (cval <= now) {
>>> +               /*
>>> +                * Timer has already expired while we were not
>>> +                * looking. Inject the interrupt and carry on.
>>> +                */
>>> +               kvm_timer_inject_irq(vcpu);
>>> +               return;
>>> +       }
>>> +
>>> +       ns = cyclecounter_cyc2ns(timecounter->cc, cval - now);
>>> +       timer_arm(timer, ns);
>>> +}
>>
>> Please use flush/sync terminology to match the rest of arch/arm/.
>>
> ok, the following fixes this for both timers and the vgic:
> 
> commit 1b68f39459dbc797f6766c103edf2c1053984161
> Author: Christoffer Dall <c.dall@virtualopensystems.com>
> Date:   Mon Jan 14 14:16:31 2013 -0500
> 
>     KVM: ARM: vgic: use sync/flush terminology
> 
>     Use sync/flush for saving state to/from CPUs to be consistent with
>     other uses in arch/arm.

Sync and flush on their own are pretty inexpressive. Consider changing
it to {flush,sync}_hwstate, so we're consistent with what VFP does.

	M.
-- 
Jazz is not dead. It just smells funny...


  reply	other threads:[~2013-01-15 11:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 18:43 [PATCH v5 0/4] KVM/ARM Architected Timers support Christoffer Dall
2013-01-08 18:43 ` Christoffer Dall
2013-01-08 18:43 ` [PATCH v5 1/4] ARM: arch_timers: switch to physical timers if HYP mode is available Christoffer Dall
2013-01-08 18:43   ` Christoffer Dall
2013-01-08 18:43 ` [PATCH v5 2/4] ARM: KVM: arch_timers: Add guest timer core support Christoffer Dall
2013-01-08 18:43   ` Christoffer Dall
2013-01-14 15:18   ` Will Deacon
2013-01-14 15:18     ` Will Deacon
2013-01-14 19:19     ` Christoffer Dall
2013-01-14 19:19       ` Christoffer Dall
2013-01-15 11:07       ` Marc Zyngier [this message]
2013-01-15 11:07         ` Marc Zyngier
2013-01-15 14:32         ` Christoffer Dall
2013-01-15 14:32           ` Christoffer Dall
2013-01-08 18:43 ` [PATCH v5 3/4] ARM: KVM: arch_timers: Add timer world switch Christoffer Dall
2013-01-08 18:43   ` Christoffer Dall
2013-01-14 15:21   ` Will Deacon
2013-01-14 15:21     ` Will Deacon
2013-01-14 17:51     ` Marc Zyngier
2013-01-14 17:51       ` Marc Zyngier
2013-01-14 22:08       ` Christoffer Dall
2013-01-14 22:08         ` Christoffer Dall
2013-01-14 22:25         ` Will Deacon
2013-01-14 22:25           ` Will Deacon
2013-01-15 11:10         ` Marc Zyngier
2013-01-15 11:10           ` Marc Zyngier
2013-01-08 18:43 ` [PATCH v5 4/4] ARM: KVM: arch_timers: Wire the init code and config option Christoffer Dall
2013-01-08 18:43   ` Christoffer Dall

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=50F53868.4060208@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.