From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Keir Fraser <keir@xen.org>, Jan Beulich <JBeulich@suse.com>,
Tim Deegan <tim@xen.org>
Subject: [Patch v4 3/5] x86/hpet: Post cleanup
Date: Wed, 13 Nov 2013 17:59:12 +0000 [thread overview]
Message-ID: <1384365554-11017-4-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1384365554-11017-1-git-send-email-andrew.cooper3@citrix.com>
These changes are ones which were able to be pulled out of the previous patch.
They are all misc cleanup without functional implications
* Shift HPET_EVT_* definitions up now that USED has moved out
* Shuffle struct hpet_event_channel
** Reflow horizontally and comment current use
** Promote 'shift' to unsigned. It is the constant 32 but can be more easily
optimised.
** Move 'flags' up to fill 4 byte hole
** Move 'cpumask' and 'lock' into second cache line as they are diried from
other cpus
* The new locking requirements guarentee that interrupts are disabled in
hpet_set_counter. Leave an ASSERT() just in case.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
---
xen/arch/x86/hpet.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index 20339b4..0bb3c31 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -19,22 +19,22 @@
#define MAX_DELTA_NS MILLISECS(10*1000)
#define MIN_DELTA_NS MICROSECS(20)
-#define HPET_EVT_DISABLE_BIT 1
+#define HPET_EVT_DISABLE_BIT 0
#define HPET_EVT_DISABLE (1 << HPET_EVT_DISABLE_BIT)
-#define HPET_EVT_LEGACY_BIT 2
+#define HPET_EVT_LEGACY_BIT 1
#define HPET_EVT_LEGACY (1 << HPET_EVT_LEGACY_BIT)
struct hpet_event_channel
{
- unsigned long mult;
- int shift;
- s_time_t next_event;
- cpumask_var_t cpumask;
- spinlock_t lock;
- unsigned int idx; /* physical channel idx */
- unsigned int cpu; /* msi target */
- struct msi_desc msi;/* msi state */
- unsigned int flags; /* HPET_EVT_x */
+ unsigned long mult; /* tick <-> time conversion */
+ unsigned int shift; /* tick <-> time conversion */
+ unsigned int flags; /* HPET_EVT_x */
+ s_time_t next_event; /* expected time of next interrupt */
+ unsigned int idx; /* HPET counter index */
+ unsigned int cpu; /* owner of channel (or -1) */
+ struct msi_desc msi; /* msi state */
+ cpumask_var_t cpumask; /* cpus wishing to be woken */
+ spinlock_t lock;
} __cacheline_aligned;
static struct hpet_event_channel *__read_mostly hpet_events;
@@ -107,14 +107,13 @@ static inline unsigned long ns2ticks(unsigned long nsec, int shift,
static int hpet_set_counter(struct hpet_event_channel *ch, unsigned long delta)
{
uint32_t cnt, cmp;
- unsigned long flags;
- local_irq_save(flags);
+ ASSERT(!local_irq_is_enabled());
+
cnt = hpet_read32(HPET_COUNTER);
cmp = cnt + delta;
hpet_write32(cmp, HPET_Tn_CMP(ch->idx));
cmp = hpet_read32(HPET_COUNTER);
- local_irq_restore(flags);
/* Are we within two ticks of the deadline passing? Then we may miss. */
return ((cmp + 2 - cnt) > delta) ? -ETIME : 0;
--
1.7.10.4
next prev parent reply other threads:[~2013-11-13 17:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 17:59 [RFC v4 0/5] HPET fix interrupt logic Andrew Cooper
2013-11-13 17:59 ` [Patch v4 1/5] x86/hpet: Pre cleanup Andrew Cooper
2013-11-13 17:59 ` [Patch v4 2/5] x86/hpet: Use singe apic vector rather than irq_descs for HPET interrupts Andrew Cooper
2013-11-14 15:52 ` Tim Deegan
2013-11-14 15:56 ` Andrew Cooper
2013-11-14 16:01 ` [Patch v5 " Andrew Cooper
2013-11-22 15:45 ` Jan Beulich
2013-11-22 16:23 ` Andrew Cooper
2013-11-22 16:49 ` Jan Beulich
2013-11-22 17:38 ` Andrew Cooper
2013-11-25 7:52 ` Jan Beulich
2013-11-25 7:50 ` Jan Beulich
2013-11-26 18:32 ` Andrew Cooper
2013-11-27 8:35 ` Jan Beulich
2013-11-27 22:37 ` Andrew Cooper
2013-11-28 14:33 ` Jan Beulich
2013-11-28 15:06 ` Andrew Cooper
2013-11-13 17:59 ` Andrew Cooper [this message]
2013-11-13 17:59 ` [Patch v4 4/5] x86/hpet: Debug and verbose hpet logging Andrew Cooper
2013-11-13 17:59 ` [Patch v4 5/5] x86/hpet: debug keyhandlers 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=1384365554-11017-4-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--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).