@@ -174,7 +174,7 @@ static int **evtchn_to_irq;
174174#ifdef CONFIG_X86
175175static unsigned long * pirq_eoi_map ;
176176#endif
177- static bool (* pirq_needs_eoi )(unsigned irq );
177+ static bool (* pirq_needs_eoi )(struct irq_info * info );
178178
179179#define EVTCHN_ROW (e ) (e / (PAGE_SIZE/sizeof(**evtchn_to_irq)))
180180#define EVTCHN_COL (e ) (e % (PAGE_SIZE/sizeof(**evtchn_to_irq)))
@@ -190,7 +190,6 @@ static struct irq_chip xen_lateeoi_chip;
190190static struct irq_chip xen_percpu_chip ;
191191static struct irq_chip xen_pirq_chip ;
192192static void enable_dynirq (struct irq_data * data );
193- static void disable_dynirq (struct irq_data * data );
194193
195194static DEFINE_PER_CPU (unsigned int , irq_epoch ) ;
196195
@@ -454,10 +453,8 @@ static unsigned int virq_from_irq(struct irq_info *info)
454453 return info -> u .virq ;
455454}
456455
457- static unsigned pirq_from_irq (unsigned irq )
456+ static unsigned int pirq_from_irq (struct irq_info * info )
458457{
459- struct irq_info * info = info_for_irq (irq );
460-
461458 BUG_ON (info == NULL );
462459 BUG_ON (info -> type != IRQT_PIRQ );
463460
@@ -500,15 +497,14 @@ static void do_unmask(struct irq_info *info, u8 reason)
500497}
501498
502499#ifdef CONFIG_X86
503- static bool pirq_check_eoi_map (unsigned irq )
500+ static bool pirq_check_eoi_map (struct irq_info * info )
504501{
505- return test_bit (pirq_from_irq (irq ), pirq_eoi_map );
502+ return test_bit (pirq_from_irq (info ), pirq_eoi_map );
506503}
507504#endif
508505
509- static bool pirq_needs_eoi_flag (unsigned irq )
506+ static bool pirq_needs_eoi_flag (struct irq_info * info )
510507{
511- struct irq_info * info = info_for_irq (irq );
512508 BUG_ON (info -> type != IRQT_PIRQ );
513509
514510 return info -> u .pirq .flags & PIRQ_NEEDS_EOI ;
@@ -802,14 +798,11 @@ static void event_handler_exit(struct irq_info *info)
802798 clear_evtchn (info -> evtchn );
803799}
804800
805- static void pirq_query_unmask (int irq )
801+ static void pirq_query_unmask (struct irq_info * info )
806802{
807803 struct physdev_irq_status_query irq_status ;
808- struct irq_info * info = info_for_irq (irq );
809804
810- BUG_ON (info -> type != IRQT_PIRQ );
811-
812- irq_status .irq = pirq_from_irq (irq );
805+ irq_status .irq = pirq_from_irq (info );
813806 if (HYPERVISOR_physdev_op (PHYSDEVOP_irq_status_query , & irq_status ))
814807 irq_status .flags = 0 ;
815808
@@ -818,56 +811,76 @@ static void pirq_query_unmask(int irq)
818811 info -> u .pirq .flags |= PIRQ_NEEDS_EOI ;
819812}
820813
821- static void eoi_pirq (struct irq_data * data )
814+ static void do_eoi_pirq (struct irq_info * info )
822815{
823- struct irq_info * info = info_for_irq (data -> irq );
824- evtchn_port_t evtchn = info ? info -> evtchn : 0 ;
825- struct physdev_eoi eoi = { .irq = pirq_from_irq (data -> irq ) };
816+ struct physdev_eoi eoi = { .irq = pirq_from_irq (info ) };
826817 int rc = 0 ;
827818
828- if (!VALID_EVTCHN (evtchn ))
819+ if (!VALID_EVTCHN (info -> evtchn ))
829820 return ;
830821
831822 event_handler_exit (info );
832823
833- if (pirq_needs_eoi (data -> irq )) {
824+ if (pirq_needs_eoi (info )) {
834825 rc = HYPERVISOR_physdev_op (PHYSDEVOP_eoi , & eoi );
835826 WARN_ON (rc );
836827 }
837828}
838829
830+ static void eoi_pirq (struct irq_data * data )
831+ {
832+ struct irq_info * info = info_for_irq (data -> irq );
833+
834+ do_eoi_pirq (info );
835+ }
836+
837+ static void do_disable_dynirq (struct irq_info * info )
838+ {
839+ if (VALID_EVTCHN (info -> evtchn ))
840+ do_mask (info , EVT_MASK_REASON_EXPLICIT );
841+ }
842+
843+ static void disable_dynirq (struct irq_data * data )
844+ {
845+ struct irq_info * info = info_for_irq (data -> irq );
846+
847+ if (info )
848+ do_disable_dynirq (info );
849+ }
850+
839851static void mask_ack_pirq (struct irq_data * data )
840852{
841- disable_dynirq (data );
842- eoi_pirq (data );
853+ struct irq_info * info = info_for_irq (data -> irq );
854+
855+ if (info ) {
856+ do_disable_dynirq (info );
857+ do_eoi_pirq (info );
858+ }
843859}
844860
845- static unsigned int __startup_pirq (unsigned int irq )
861+ static unsigned int __startup_pirq (struct irq_info * info )
846862{
847863 struct evtchn_bind_pirq bind_pirq ;
848- struct irq_info * info = info_for_irq (irq );
849- evtchn_port_t evtchn = evtchn_from_irq (irq );
864+ evtchn_port_t evtchn = info -> evtchn ;
850865 int rc ;
851866
852- BUG_ON (info -> type != IRQT_PIRQ );
853-
854867 if (VALID_EVTCHN (evtchn ))
855868 goto out ;
856869
857- bind_pirq .pirq = pirq_from_irq (irq );
870+ bind_pirq .pirq = pirq_from_irq (info );
858871 /* NB. We are happy to share unless we are probing. */
859872 bind_pirq .flags = info -> u .pirq .flags & PIRQ_SHAREABLE ?
860873 BIND_PIRQ__WILL_SHARE : 0 ;
861874 rc = HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq , & bind_pirq );
862875 if (rc != 0 ) {
863- pr_warn ("Failed to obtain physical IRQ %d\n" , irq );
876+ pr_warn ("Failed to obtain physical IRQ %d\n" , info -> irq );
864877 return 0 ;
865878 }
866879 evtchn = bind_pirq .port ;
867880
868- pirq_query_unmask (irq );
881+ pirq_query_unmask (info );
869882
870- rc = set_evtchn_to_irq (evtchn , irq );
883+ rc = set_evtchn_to_irq (evtchn , info -> irq );
871884 if (rc )
872885 goto err ;
873886
@@ -881,26 +894,28 @@ static unsigned int __startup_pirq(unsigned int irq)
881894out :
882895 do_unmask (info , EVT_MASK_REASON_EXPLICIT );
883896
884- eoi_pirq ( irq_get_irq_data ( irq ) );
897+ do_eoi_pirq ( info );
885898
886899 return 0 ;
887900
888901err :
889- pr_err ("irq%d: Failed to set port to irq mapping (%d)\n" , irq , rc );
902+ pr_err ("irq%d: Failed to set port to irq mapping (%d)\n" , info -> irq ,
903+ rc );
890904 xen_evtchn_close (evtchn );
891905 return 0 ;
892906}
893907
894908static unsigned int startup_pirq (struct irq_data * data )
895909{
896- return __startup_pirq (data -> irq );
910+ struct irq_info * info = info_for_irq (data -> irq );
911+
912+ return __startup_pirq (info );
897913}
898914
899915static void shutdown_pirq (struct irq_data * data )
900916{
901- unsigned int irq = data -> irq ;
902- struct irq_info * info = info_for_irq (irq );
903- evtchn_port_t evtchn = evtchn_from_irq (irq );
917+ struct irq_info * info = info_for_irq (data -> irq );
918+ evtchn_port_t evtchn = info -> evtchn ;
904919
905920 BUG_ON (info -> type != IRQT_PIRQ );
906921
@@ -1035,7 +1050,7 @@ int xen_bind_pirq_gsi_to_irq(unsigned gsi,
10351050 goto out ;
10361051 }
10371052
1038- pirq_query_unmask (info -> irq );
1053+ pirq_query_unmask (info );
10391054 /* We try to use the handler with the appropriate semantic for the
10401055 * type of interrupt: if the interrupt is an edge triggered
10411056 * interrupt we use handle_edge_irq.
@@ -1162,7 +1177,9 @@ int xen_destroy_irq(int irq)
11621177
11631178int xen_pirq_from_irq (unsigned irq )
11641179{
1165- return pirq_from_irq (irq );
1180+ struct irq_info * info = info_for_irq (irq );
1181+
1182+ return pirq_from_irq (info );
11661183}
11671184EXPORT_SYMBOL_GPL (xen_pirq_from_irq );
11681185
@@ -1824,28 +1841,30 @@ static void enable_dynirq(struct irq_data *data)
18241841 do_unmask (info , EVT_MASK_REASON_EXPLICIT );
18251842}
18261843
1827- static void disable_dynirq (struct irq_data * data )
1844+ static void do_ack_dynirq (struct irq_info * info )
18281845{
1829- struct irq_info * info = info_for_irq (data -> irq );
1830- evtchn_port_t evtchn = info ? info -> evtchn : 0 ;
1846+ evtchn_port_t evtchn = info -> evtchn ;
18311847
18321848 if (VALID_EVTCHN (evtchn ))
1833- do_mask (info , EVT_MASK_REASON_EXPLICIT );
1849+ event_handler_exit (info );
18341850}
18351851
18361852static void ack_dynirq (struct irq_data * data )
18371853{
18381854 struct irq_info * info = info_for_irq (data -> irq );
1839- evtchn_port_t evtchn = info ? info -> evtchn : 0 ;
18401855
1841- if (VALID_EVTCHN ( evtchn ) )
1842- event_handler_exit (info );
1856+ if (info )
1857+ do_ack_dynirq (info );
18431858}
18441859
18451860static void mask_ack_dynirq (struct irq_data * data )
18461861{
1847- disable_dynirq (data );
1848- ack_dynirq (data );
1862+ struct irq_info * info = info_for_irq (data -> irq );
1863+
1864+ if (info ) {
1865+ do_disable_dynirq (info );
1866+ do_ack_dynirq (info );
1867+ }
18491868}
18501869
18511870static void lateeoi_ack_dynirq (struct irq_data * data )
@@ -1924,7 +1943,7 @@ static void restore_pirqs(void)
19241943
19251944 printk (KERN_DEBUG "xen: --> irq=%d, pirq=%d\n" , irq , map_irq .pirq );
19261945
1927- __startup_pirq (irq );
1946+ __startup_pirq (info );
19281947 }
19291948}
19301949
0 commit comments