aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-06 12:42:43 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-11 13:19:29 -0400
commited89eb6396b3307bf9aaa4785f6a0914a68040cf (patch)
tree30ee8cbcdfa848afa0aa141724eab860207ba290
parent30bd35edfd5c82147bdcf0540c6bd3cf92d101f8 (diff)
xen/pci: Use the xen_register_pirq for HVM and initial domain users
.. to cut down on the code duplicity. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r--arch/x86/pci/xen.c75
1 files changed, 23 insertions, 52 deletions
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 6b7d849905c..55c8cc3647a 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -62,60 +62,19 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)
62} 62}
63 63
64#ifdef CONFIG_ACPI 64#ifdef CONFIG_ACPI
65static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi, 65static int xen_register_pirq(u32 gsi, int gsi_override, int triggering,
66 int trigger, int polarity) 66 bool alloc_pirq)
67{ 67{
68 int rc, irq; 68 int rc, pirq = -1, irq = -1;
69 struct physdev_map_pirq map_irq; 69 struct physdev_map_pirq map_irq;
70 int shareable = 0; 70 int shareable = 0;
71 char *name; 71 char *name;
72 72
73 if (!xen_hvm_domain()) 73 if (alloc_pirq) {
74 return -1; 74 pirq = xen_allocate_pirq_gsi(gsi);
75 75 if (pirq < 0)
76 map_irq.domid = DOMID_SELF; 76 goto out;
77 map_irq.type = MAP_PIRQ_TYPE_GSI;
78 map_irq.index = gsi;
79 map_irq.pirq = -1;
80
81 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
82 if (rc) {
83 printk(KERN_WARNING "xen map irq failed %d\n", rc);
84 return -1;
85 }
86
87 if (trigger == ACPI_EDGE_SENSITIVE) {
88 shareable = 0;
89 name = "ioapic-edge";
90 } else {
91 shareable = 1;
92 name = "ioapic-level";
93 } 77 }
94
95 irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name);
96
97 printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq);
98
99 return irq;
100}
101#endif
102
103#ifdef CONFIG_XEN_DOM0
104#ifdef CONFIG_ACPI
105static int xen_register_pirq(u32 gsi, int gsi_override, int triggering)
106{
107 int rc, pirq, irq = -1;
108 struct physdev_map_pirq map_irq;
109 int shareable = 0;
110 char *name;
111
112 if (!xen_pv_domain())
113 return -1;
114
115 pirq = xen_allocate_pirq_gsi(gsi);
116 if (pirq < 0)
117 goto out;
118
119 map_irq.domid = DOMID_SELF; 78 map_irq.domid = DOMID_SELF;
120 map_irq.type = MAP_PIRQ_TYPE_GSI; 79 map_irq.type = MAP_PIRQ_TYPE_GSI;
121 map_irq.index = gsi; 80 map_irq.index = gsi;
@@ -138,15 +97,26 @@ static int xen_register_pirq(u32 gsi, int gsi_override, int triggering)
138 if (gsi_override >= 0) 97 if (gsi_override >= 0)
139 gsi = gsi_override; 98 gsi = gsi_override;
140 99
141 irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name); 100 irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name);
142 if (irq < 0) 101 if (irq < 0)
143 goto out; 102 goto out;
144 103
145 printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d (gsi=%d)\n", pirq, irq, gsi); 104 printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d (gsi=%d)\n", map_irq.pirq, irq, gsi);
146out: 105out:
147 return irq; 106 return irq;
148} 107}
149 108
109static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
110 int trigger, int polarity)
111{
112 if (!xen_hvm_domain())
113 return -1;
114
115 return xen_register_pirq(gsi, -1 /* no GSI override */,
116 trigger, false /* no PIRQ allocation */);
117}
118
119#ifdef CONFIG_XEN_DOM0
150static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polarity) 120static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polarity)
151{ 121{
152 int rc, irq; 122 int rc, irq;
@@ -158,7 +128,7 @@ static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polar
158 printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n", 128 printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n",
159 gsi, triggering, polarity); 129 gsi, triggering, polarity);
160 130
161 irq = xen_register_pirq(gsi, gsi_override, triggering); 131 irq = xen_register_pirq(gsi, gsi_override, triggering, true);
162 132
163 setup_gsi.gsi = gsi; 133 setup_gsi.gsi = gsi;
164 setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1); 134 setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1);
@@ -497,7 +467,8 @@ void __init xen_setup_pirqs(void)
497 continue; 467 continue;
498 468
499 xen_register_pirq(irq, -1 /* no GSI override */, 469 xen_register_pirq(irq, -1 /* no GSI override */,
500 trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE); 470 trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE,
471 true /* allocate IRQ */);
501 } 472 }
502#endif 473#endif
503} 474}