From: Don Slutz <dslutz@verizon.com>
To: Jan Beulich <JBeulich@suse.com>, Don Slutz <dslutz@verizon.com>
Cc: Keir Fraser <keir@xen.org>, xen-devel@lists.xen.org
Subject: Re: [PATCH v2 03/10] hvm/hpet: Only set comparator or period not both.
Date: Mon, 14 Apr 2014 18:53:34 -0400 [thread overview]
Message-ID: <534C66EE.2050303@terremark.com> (raw)
In-Reply-To: <534C13B6020000780000889D@nat28.tlf.novell.com>
On 04/14/14 10:58, Jan Beulich wrote:
>>>> On 08.04.14 at 16:24, <dslutz@verizon.com> wrote:
> The if() is clearly unnecessary here, and with it removed I don't see
> any difference left with the inner if() path above. Hence I guess
> they should be folded. Once that's done, new_val as calculated
> before the outer if() isn't needed in the inner "else" path, and
> hence its truncation could be moved inside the if(). Which in turn
> allows you to fix the comparator64 related bug here too: All other
> code stores the non-truncated value there, just the code here
> doesn't.
>
> Jan
If I understand this correctly, this leads to the following change
(Hopefully not line wrapped):
diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c
index c3f286f..913beb1 100644
--- a/xen/arch/x86/hvm/hpet.c
+++ b/xen/arch/x86/hvm/hpet.c
@@ -404,20 +404,8 @@ static int hpet_write(
case HPET_Tn_CMP(1):
case HPET_Tn_CMP(2):
tn = HPET_TN(CMP, addr);
- if ( timer_is_32bit(h, tn) )
- new_val = (uint32_t)new_val;
- h->hpet.timers[tn].cmp = new_val;
- if ( h->hpet.timers[tn].config & HPET_TN_SETVAL )
- /*
- * When SETVAL is one, software is able to "directly set a periodic
- * timer's accumulator." That is, set the comparator without
- * adjusting the period. Much the same as just setting the
- * comparator on an enabled one-shot timer.
- *
- * This configuration bit clears when the comparator is written.
- */
- h->hpet.timers[tn].config &= ~HPET_TN_SETVAL;
- else if ( timer_is_periodic(h, tn) )
+ if ( timer_is_periodic(h, tn) &&
+ !(h->hpet.timers[tn].config & HPET_TN_SETVAL) )
{
/*
* Clamp period to reasonable min/max values:
@@ -429,7 +417,25 @@ static int hpet_write(
new_val &= (timer_is_32bit(h, tn) ? ~0u : ~0ull) >> 1;
h->hpet.period[tn] = new_val;
}
- h->hpet.comparator64[tn] = new_val;
+ else
+ {
+ /*
+ * When SETVAL is one, software is able to "directly set
+ * a periodic timer's accumulator." That is, set the
+ * comparator without adjusting the period. Much the
+ * same as just setting the comparator on an enabled
+ * one-shot timer.
+ *
+ * This configuration bit clears when the comparator is
+ * written.
+ */
+ h->hpet.timers[tn].config &= ~HPET_TN_SETVAL;
+ h->hpet.comparator64[tn] = new_val;
+ if ( timer_is_32bit(h, tn) )
+ h->hpet.timers[tn].cmp = (uint32_t)new_val;
+ else
+ h->hpet.timers[tn].cmp = new_val;
+ }
if ( hpet_enabled(h) && timer_enabled(h, tn) )
set_restart_timer(tn);
break;
I am still testing that this re-write still does the "right
thing". Which is why it is yet to be a v3. This preview
is sent to check that I did correctly do the requested change.
-Don Slutz
next prev parent reply other threads:[~2014-04-14 22:53 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-08 14:24 [PATCH v2 00/10] Prevent one cause of "MP-BIOS bug: 8254 timer"... message from linux Don Slutz
2014-04-08 14:24 ` [PATCH v2 01/10] hvm/hpet: Add manual unit test code Don Slutz
2014-04-09 16:08 ` Jan Beulich
2014-04-09 18:35 ` Don Slutz
2014-04-10 6:11 ` Jan Beulich
2014-04-11 2:53 ` Don Slutz
2014-04-11 7:45 ` Jan Beulich
2014-04-11 11:57 ` [PATCH optional " Don Slutz
2014-04-11 12:09 ` Jan Beulich
2014-04-11 12:48 ` Don Slutz
2014-04-11 15:14 ` Jan Beulich
2014-04-11 17:40 ` Don Slutz
2014-04-14 7:40 ` Jan Beulich
2014-04-14 17:29 ` test_x86_emulator (was Re: [PATCH optional v2 01/10] hvm/hpet: Add manual unit test code.) Don Slutz
2014-04-15 6:49 ` test_x86_emulator Jan Beulich
2014-04-15 14:24 ` test_x86_emulator Don Slutz
2014-04-16 8:26 ` test_x86_emulator Jan Beulich
2014-04-16 9:32 ` test_x86_emulator Keir Fraser
2014-04-16 15:21 ` test_x86_emulator Don Slutz
2014-04-08 14:24 ` [PATCH v2 02/10] hvm/hpet: Only call guest_time_hpet(h) one time per action Don Slutz
2014-04-14 14:31 ` Jan Beulich
2014-04-14 17:38 ` Don Slutz
2014-04-08 14:24 ` [PATCH v2 03/10] hvm/hpet: Only set comparator or period not both Don Slutz
2014-04-14 14:58 ` Jan Beulich
2014-04-14 22:53 ` Don Slutz [this message]
2014-04-15 6:59 ` Jan Beulich
2014-04-16 4:06 ` Don Slutz
2014-04-08 14:24 ` [PATCH v2 04/10] hvm/hpet: In hpet_save, correctly compute mc64 Don Slutz
2014-04-08 14:24 ` [PATCH v2 05/10] hvm/hpet: Init comparator64 like comparator Don Slutz
2014-04-08 14:24 ` [PATCH v2 06/10] hvm/hpet: comparator can only change when master clock is enabled Don Slutz
2014-04-14 15:07 ` Jan Beulich
2014-04-14 19:50 ` Don Slutz
2014-04-15 7:05 ` Jan Beulich
2014-04-15 15:53 ` Don Slutz
2014-04-15 16:14 ` Jan Beulich
2014-04-15 18:11 ` Don Slutz
2014-04-16 8:42 ` Jan Beulich
2014-04-08 14:24 ` [PATCH v2 07/10] hvm/hpet: Call hpet_get_comparator during hpet_save Don Slutz
2014-04-14 15:13 ` Jan Beulich
2014-04-15 0:21 ` Don Slutz
2014-04-15 7:06 ` Jan Beulich
2014-04-15 14:18 ` Don Slutz
2014-04-08 14:24 ` [PATCH v2 08/10] hvm/hpet: Prevent master clock equal to comparator while enabled Don Slutz
2014-04-08 14:24 ` [PATCH v2 09/10] hvm/hpet: Correctly limit period to a maximum Don Slutz
2014-04-08 14:24 ` [PATCH v2 10/10] hvm/hpet: handle 1st period special Don Slutz
2014-04-14 15:27 ` Jan Beulich
2014-04-15 0:21 ` Don Slutz
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=534C66EE.2050303@terremark.com \
--to=dslutz@verizon.com \
--cc=JBeulich@suse.com \
--cc=keir@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).