]> xenbits.xensource.com Git - people/julieng/xen-unstable.git/commitdiff
x86: allow disabling power management
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 10 Nov 2015 11:06:48 +0000 (12:06 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 10 Nov 2015 11:06:48 +0000 (12:06 +0100)
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/pmtimer.c

index c8229e0eab68ae136827ef3efff7b85e35289b19..9c2e4bd2d818d2cf57805e127c1c2034119dcfff 100644 (file)
@@ -67,6 +67,10 @@ static void pmt_update_sci(PMTState *s)
 void hvm_acpi_power_button(struct domain *d)
 {
     PMTState *s = &d->arch.hvm_domain.pl_time.vpmt;
+
+    if ( !has_vpm(d) )
+        return;
+
     spin_lock(&s->lock);
     s->pm.pm1a_sts |= PWRBTN_STS;
     pmt_update_sci(s);
@@ -76,6 +80,10 @@ void hvm_acpi_power_button(struct domain *d)
 void hvm_acpi_sleep_button(struct domain *d)
 {
     PMTState *s = &d->arch.hvm_domain.pl_time.vpmt;
+
+    if ( !has_vpm(d) )
+        return;
+
     spin_lock(&s->lock);
     s->pm.pm1a_sts |= SLPBTN_STS;
     pmt_update_sci(s);
@@ -247,6 +255,9 @@ static int pmtimer_save(struct domain *d, hvm_domain_context_t *h)
     uint32_t x, msb = s->pm.tmr_val & TMR_VAL_MSB;
     int rc;
 
+    if ( !has_vpm(d) )
+        return 0;
+
     spin_lock(&s->lock);
 
     /*
@@ -273,6 +284,9 @@ static int pmtimer_load(struct domain *d, hvm_domain_context_t *h)
 {
     PMTState *s = &d->arch.hvm_domain.pl_time.vpmt;
 
+    if ( !has_vpm(d) )
+        return -ENODEV;
+
     spin_lock(&s->lock);
 
     /* Reload the registers */
@@ -301,6 +315,9 @@ int pmtimer_change_ioport(struct domain *d, unsigned int version)
 {
     unsigned int old_version;
 
+    if ( !has_vpm(d) )
+        return -ENODEV;
+
     /* Check that version is changing. */
     old_version = d->arch.hvm_domain.params[HVM_PARAM_ACPI_IOPORTS_LOCATION];
     if ( version == old_version )
@@ -330,6 +347,9 @@ void pmtimer_init(struct vcpu *v)
 {
     PMTState *s = &v->domain->arch.hvm_domain.pl_time.vpmt;
 
+    if ( !has_vpm(v->domain) )
+        return;
+
     spin_lock_init(&s->lock);
 
     s->scale = ((uint64_t)FREQUENCE_PMTIMER << 32) / SYSTEM_TIME_HZ;
@@ -350,11 +370,18 @@ void pmtimer_init(struct vcpu *v)
 void pmtimer_deinit(struct domain *d)
 {
     PMTState *s = &d->arch.hvm_domain.pl_time.vpmt;
+
+    if ( !has_vpm(d) )
+        return;
+
     kill_timer(&s->timer);
 }
 
 void pmtimer_reset(struct domain *d)
 {
+    if ( !has_vpm(d) )
+        return;
+
     /* Reset the counter. */
     d->arch.hvm_domain.pl_time.vpmt.pm.tmr_val = 0;
 }