linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jennifer Herbert <jennifer.herbert@citrix.com>
To: <x86@kernel.org>, <xen-devel@lists.xenproject.org>,
	<linux-kernel@vger.kernel.org>
Cc: Jennifer Herbert <jennifer.herbert@citrix.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH] xen/pv: Add PV specific legacy_pic struct to expose legacy IRQs.
Date: Tue, 19 Mar 2019 20:02:19 +0000	[thread overview]
Message-ID: <1553025739-92245-1-git-send-email-jennifer.herbert@citrix.com> (raw)

The ACPI tables doesn't always contain all IRQs for legacy devices
such as RTC.  Since no PIC controller is visible for a PV linux guest,
under Xen, legacy_pic currently defaults to the null_legacy_pic - with
reports no legacy IRQs.  Since the commit "rtc: cmos: Do not assume
irq 8 for rtc when there are no legacy irqs" by Hans de Goede
(commit id: a1e23a42f1bdc00e32fc4869caef12e4e6272f26), the rtc now
incorrectly decides it has no irq it can use, for some hardware.

This patch rectifies the problem by providing a xen legacy_pic
struct, which is much like the null_legacy_pic except that it
reports NR_IRQS_LEGACY irqs.

Signed-off-by: Jennifer Herbert <jennifer.herbert@citrix.com>
---
 arch/x86/xen/enlighten_pv.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index c54a493..7644bdf 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -33,6 +33,7 @@
 #include <linux/gfp.h>
 #include <linux/edd.h>
 #include <linux/frame.h>
+#include <linux/irq.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -49,6 +50,7 @@
 #include <xen/acpi.h>
 
 #include <asm/paravirt.h>
+#include <asm/i8259.h>
 #include <asm/apic.h>
 #include <asm/page.h>
 #include <asm/xen/pci.h>
@@ -1188,6 +1190,41 @@ static void __init xen_dom0_set_legacy_features(void)
 	x86_platform.legacy.rtc = 1;
 }
 
+/*
+ * The ACPI tables doesn't always contain all IRQ's for legacy devices
+ * such as RTC.  Since no PIC controller is visible, we'd otherwise
+ * default to the null_legacy_pic - with no legacy IRQs.  To allow drivers
+ * to use these IRQs despite this, provide a xen specific legacy_pic
+ * structure, which is noop, other then reporting NR_IRQS_LEGACY irqs.
+ */
+
+static void xen_legacy_pic_noop(void) { };
+static void xen_legacy_pic_uint_noop(unsigned int unused) { };
+static void xen_legacy_pic_int_noop(int unused) { };
+static int xen_legacy_pic_irq_pending_noop(unsigned int irq)
+{
+	return 0;
+}
+
+static int xen_legacy_pic_probe(void)
+{
+	pr_info("Using Xen legacy PIC\n");
+	return nr_legacy_irqs();
+}
+
+struct legacy_pic xen_legacy_pic = {
+	.nr_legacy_irqs = NR_IRQS_LEGACY,
+	.chip = &dummy_irq_chip,
+	.mask = xen_legacy_pic_uint_noop,
+	.unmask = xen_legacy_pic_uint_noop,
+	.mask_all = xen_legacy_pic_noop,
+	.restore_mask = xen_legacy_pic_noop,
+	.init = xen_legacy_pic_int_noop,
+	.probe = xen_legacy_pic_probe,
+	.irq_pending = xen_legacy_pic_irq_pending_noop,
+	.make_irq = xen_legacy_pic_uint_noop,
+};
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
@@ -1267,6 +1304,8 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
 	xen_init_capabilities();
 
+	legacy_pic = &xen_legacy_pic;
+
 #ifdef CONFIG_X86_LOCAL_APIC
 	/*
 	 * set up the basic apic ops.
-- 
1.8.3.1


             reply	other threads:[~2019-03-19 20:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 20:02 Jennifer Herbert [this message]
2019-03-19 23:06 ` [PATCH] xen/pv: Add PV specific legacy_pic struct to expose legacy IRQs Boris Ostrovsky
2019-03-21 17:49   ` Jennifer Herbert
2019-03-25 14:23     ` [Xen-devel] " Jennifer Herbert
2019-03-25 14:40       ` Paul Durrant
2019-03-27 15:02         ` Boris Ostrovsky

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=1553025739-92245-1-git-send-email-jennifer.herbert@citrix.com \
    --to=jennifer.herbert@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.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).