2020#include <linux/kvm_host.h>
2121#include <linux/interrupt.h>
2222#include <linux/io.h>
23- #include <linux/of.h>
24- #include <linux/of_address.h>
25- #include <linux/of_irq.h>
2623
2724#include <linux/irqchip/arm-gic.h>
2825
@@ -186,38 +183,39 @@ static void vgic_cpu_init_lrs(void *params)
186183}
187184
188185/**
189- * vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT
190- * @node : pointer to the DT node
191- * @ops: address of a pointer to the GICv2 operations
192- * @params: address of a pointer to HW-specific parameters
186+ * vgic_v2_probe - probe for a GICv2 compatible interrupt controller
187+ * @gic_kvm_info : pointer to the GIC description
188+ * @ops: address of a pointer to the GICv2 operations
189+ * @params: address of a pointer to HW-specific parameters
193190 *
194191 * Returns 0 if a GICv2 has been found, with the low level operations
195192 * in *ops and the HW parameters in *params. Returns an error code
196193 * otherwise.
197194 */
198- int vgic_v2_probe (struct device_node * vgic_node ,
199- const struct vgic_ops * * ops ,
200- const struct vgic_params * * params )
195+ int vgic_v2_probe (const struct gic_kvm_info * gic_kvm_info ,
196+ const struct vgic_ops * * ops ,
197+ const struct vgic_params * * params )
201198{
202199 int ret ;
203- struct resource vctrl_res ;
204- struct resource vcpu_res ;
205200 struct vgic_params * vgic = & vgic_v2_params ;
201+ const struct resource * vctrl_res = & gic_kvm_info -> vctrl ;
202+ const struct resource * vcpu_res = & gic_kvm_info -> vcpu ;
206203
207- vgic -> maint_irq = irq_of_parse_and_map (vgic_node , 0 );
208- if (!vgic -> maint_irq ) {
209- kvm_err ("error getting vgic maintenance irq from DT\n" );
204+ if (!gic_kvm_info -> maint_irq ) {
205+ kvm_err ("error getting vgic maintenance irq\n" );
210206 ret = - ENXIO ;
211207 goto out ;
212208 }
209+ vgic -> maint_irq = gic_kvm_info -> maint_irq ;
213210
214- ret = of_address_to_resource ( vgic_node , 2 , & vctrl_res );
215- if ( ret ) {
216- kvm_err ( "Cannot obtain GICH resource\n" ) ;
211+ if (! gic_kvm_info -> vctrl . start ) {
212+ kvm_err ( "GICH not present in the firmware table\n" );
213+ ret = - ENXIO ;
217214 goto out ;
218215 }
219216
220- vgic -> vctrl_base = of_iomap (vgic_node , 2 );
217+ vgic -> vctrl_base = ioremap (gic_kvm_info -> vctrl .start ,
218+ resource_size (& gic_kvm_info -> vctrl ));
221219 if (!vgic -> vctrl_base ) {
222220 kvm_err ("Cannot ioremap GICH\n" );
223221 ret = - ENOMEM ;
@@ -228,29 +226,23 @@ int vgic_v2_probe(struct device_node *vgic_node,
228226 vgic -> nr_lr = (vgic -> nr_lr & 0x3f ) + 1 ;
229227
230228 ret = create_hyp_io_mappings (vgic -> vctrl_base ,
231- vgic -> vctrl_base + resource_size (& vctrl_res ),
232- vctrl_res . start );
229+ vgic -> vctrl_base + resource_size (vctrl_res ),
230+ vctrl_res -> start );
233231 if (ret ) {
234232 kvm_err ("Cannot map VCTRL into hyp\n" );
235233 goto out_unmap ;
236234 }
237235
238- if (of_address_to_resource (vgic_node , 3 , & vcpu_res )) {
239- kvm_err ("Cannot obtain GICV resource\n" );
240- ret = - ENXIO ;
241- goto out_unmap ;
242- }
243-
244- if (!PAGE_ALIGNED (vcpu_res .start )) {
236+ if (!PAGE_ALIGNED (vcpu_res -> start )) {
245237 kvm_err ("GICV physical address 0x%llx not page aligned\n" ,
246- (unsigned long long )vcpu_res . start );
238+ (unsigned long long )vcpu_res -> start );
247239 ret = - ENXIO ;
248240 goto out_unmap ;
249241 }
250242
251- if (!PAGE_ALIGNED (resource_size (& vcpu_res ))) {
243+ if (!PAGE_ALIGNED (resource_size (vcpu_res ))) {
252244 kvm_err ("GICV size 0x%llx not a multiple of page size 0x%lx\n" ,
253- (unsigned long long )resource_size (& vcpu_res ),
245+ (unsigned long long )resource_size (vcpu_res ),
254246 PAGE_SIZE );
255247 ret = - ENXIO ;
256248 goto out_unmap ;
@@ -259,10 +251,10 @@ int vgic_v2_probe(struct device_node *vgic_node,
259251 vgic -> can_emulate_gicv2 = true;
260252 kvm_register_device_ops (& kvm_arm_vgic_v2_ops , KVM_DEV_TYPE_ARM_VGIC_V2 );
261253
262- vgic -> vcpu_base = vcpu_res . start ;
254+ vgic -> vcpu_base = vcpu_res -> start ;
263255
264- kvm_info ("%s@ %llx IRQ%d\n" , vgic_node -> name ,
265- vctrl_res .start , vgic -> maint_irq );
256+ kvm_info ("GICH base=0x%llx, GICV base=0x %llx, IRQ= %d\n" ,
257+ gic_kvm_info -> vctrl .start , vgic -> vcpu_base , vgic -> maint_irq );
266258
267259 vgic -> type = VGIC_V2 ;
268260 vgic -> max_gic_vcpus = VGIC_V2_MAX_CPUS ;
@@ -276,6 +268,5 @@ int vgic_v2_probe(struct device_node *vgic_node,
276268out_unmap :
277269 iounmap (vgic -> vctrl_base );
278270out :
279- of_node_put (vgic_node );
280271 return ret ;
281272}
0 commit comments