Skip to contentSkip to conversation

Why xen-pirq chip use startup_irq() for .irq_enable?

PATCH [email protected] 2 participants 5 messages Jul 27, 2017 – Jul 29, 2017 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

Hi,
Here is a device has xen-pirq-MSI interrupt. I found dom0 might lost interrupt during driver irq_disable/irq_enable.
There is a pair of irq_disable/enable in driver. Here is the scenario,
1. irq_disable(dev_irq) -> disable_dynirq -> mask_evtchn(dev_irq channel)
2. dev interrupt raised by HW and Xen mark its evtchn as *pending* status.
3. irq_enable(dev_irq) -> startup_pirq -> eoi_pirq ->

    clear_evtchn(channel of dev_irq) -> clear *pending* status

4. consume_one_event process the dev irq event without pending bit assert which result in interrupt lost once.
5. No HW interrupt raising anymore.

The first question here is why using startup_irq for .irq_enable rather than enable_dynirq ? startup_irq will do eoi_pirq who clear the mask bit and pending bit of the channel while enable_dynirq just only unmask the channel.

Second question is that what's the purpose of eoi_pirq in startup_irq?

BTW, i can resolve my problem by below patch. Does it make sence?

---
drivers/xen/events/events_base.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/events/events_base.c +0 -0
index 4bf7a34..341c456 100644
@@ -582,7 +582,7 @@ static void shutdown_pirq(struct irq_data *data)
 

static void enable_pirq(struct irq_data *data)
{
- startup_pirq(data);
+ enable_dynirq(data);
}

static void disable_pirq(struct irq_data *data)

Signature · 8 lines
Thanks.
Shuo A


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

(Adjusting addressees: David is no longer maintaining Xen code, Juergen is)

Quoted 15 lines · On 07/27/2017 09:04 AM, [email protected] wrote:

Hi,
Here is a device has xen-pirq-MSI interrupt. I found dom0 might lost interrupt during driver irq_disable/irq_enable.
There is a pair of irq_disable/enable in driver. Here is the scenario,
1. irq_disable(dev_irq) -> disable_dynirq -> mask_evtchn(dev_irq
channel)
2. dev interrupt raised by HW and Xen mark its evtchn as *pending*
status.
3. irq_enable(dev_irq) -> startup_pirq -> eoi_pirq ->

    clear_evtchn(channel of dev_irq) -> clear *pending* status

4. consume_one_event process the dev irq event without pending bit
assert
which result in interrupt lost once.
5. No HW interrupt raising anymore.

Quoted 5 lines

The first question here is why using startup_irq for .irq_enable rather than
enable_dynirq ? startup_irq will do eoi_pirq who clear the mask bit and pending
bit of the channel while enable_dynirq just only unmask the channel.

Seems like enable_dynirq() would indeed be the right choice. What is a bit strange is that scenario that you are describing looks pretty common so we should have hit this problem before.

Quoted 2 lines

Second question is that what's the purpose of eoi_pirq in startup_irq?

When we are actually creating new pirq we want to make sure there are no pending interrupts left over from previous use of the pirq.

-boris

Quoted 13 lines

BTW, i can resolve my problem by below patch. Does it make sence?

---
drivers/xen/events/events_base.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/events/events_base.c +0 -0
index 4bf7a34..341c456 100644

drivers/xen/events/events_base.c static void shutdown_pirq(struct irq_data *data) · line 588

Quoted 8 lines
drivers/xen/events/events_base.c +1 -1
@@ -582,7 +582,7 @@ static void shutdown_pirq(struct irq_data *data)
 
 static void enable_pirq(struct irq_data *data)
 {
-    startup_pirq(data);
+    enable_dynirq(data);
 }
 
 static void disable_pirq(struct irq_data *data)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 1 line · Boris Ostrovsky

(Adjusting addressees: David is no longer maintaining Xen code, Juergen is)

Thanks Boris.

Quoted 23 lines · On 07/27/2017 09:04 AM, [email protected] wrote:
Quoted 15 lines

Hi,
Here is a device has xen-pirq-MSI interrupt. I found dom0 might lost interrupt during driver irq_disable/irq_enable.
There is a pair of irq_disable/enable in driver. Here is the scenario,
1. irq_disable(dev_irq) -> disable_dynirq -> mask_evtchn(dev_irq
channel)
2. dev interrupt raised by HW and Xen mark its evtchn as *pending*
status.
3. irq_enable(dev_irq) -> startup_pirq -> eoi_pirq ->

    clear_evtchn(channel of dev_irq) -> clear *pending* status

4. consume_one_event process the dev irq event without pending bit
assert
which result in interrupt lost once.
5. No HW interrupt raising anymore.

Quoted 5 lines

The first question here is why using startup_irq for .irq_enable rather than
enable_dynirq ? startup_irq will do eoi_pirq who clear the mask bit and pending
bit of the channel while enable_dynirq just only unmask the channel.

Quoted 3 lines

Seems like enable_dynirq() would indeed be the right choice. What is a bit strange is that scenario that you are describing looks pretty common so we should have hit this problem before.

This point confused me also. It seems the code has been here for long time. Anyway, if you think it is the right fix, i can send out a formal patch.

Quoted 5 lines
Quoted 2 lines

Second question is that what's the purpose of eoi_pirq in startup_irq?

When we are actually creating new pirq we want to make sure there are no pending interrupts left over from previous use of the pirq.

If interrupt raise just before eoi_pirq in startup_irq, we might face the same issue? Can we make sure pirq is clean when do binding?

Thx -
Shuo

Quoted 16 lines

-boris

Quoted 14 lines

BTW, i can resolve my problem by below patch. Does it make sence?

---
drivers/xen/events/events_base.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/events/events_base.c +0 -0
index 4bf7a34..341c456 100644
@@ -582,7 +582,7 @@ static void shutdown_pirq(struct irq_data *data)
 
Quoted 8 lines

drivers/xen/events/events_base.c static void shutdown_pirq(struct irq_data *data) · line 588

Quoted 7 lines
drivers/xen/events/events_base.c +1 -1
 static void enable_pirq(struct irq_data *data)
 {
-    startup_pirq(data);
+    enable_dynirq(data);
 }
 
 static void disable_pirq(struct irq_data *data)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 27 lines · On 07/27/2017 09:25 PM, [email protected] wrote:
Quoted 2 lines · Boris Ostrovsky

(Adjusting addressees: David is no longer maintaining Xen code, Juergen is)

Thanks Boris.

Quoted 23 lines · On 07/27/2017 09:04 AM, [email protected] wrote:
Quoted 20 lines

Hi,
Here is a device has xen-pirq-MSI interrupt. I found dom0 might lost interrupt during driver irq_disable/irq_enable.
There is a pair of irq_disable/enable in driver. Here is the scenario,
1. irq_disable(dev_irq) -> disable_dynirq -> mask_evtchn(dev_irq
channel)
2. dev interrupt raised by HW and Xen mark its evtchn as *pending*
status.
3. irq_enable(dev_irq) -> startup_pirq -> eoi_pirq ->

    clear_evtchn(channel of dev_irq) -> clear *pending* status

4. consume_one_event process the dev irq event without pending bit
assert
which result in interrupt lost once.
5. No HW interrupt raising anymore.

The first question here is why using startup_irq for .irq_enable rather than
enable_dynirq ? startup_irq will do eoi_pirq who clear the mask bit and pending
bit of the channel while enable_dynirq just only unmask the channel.

Quoted 6 lines
Quoted 3 lines

Seems like enable_dynirq() would indeed be the right choice. What is a bit strange is that scenario that you are describing looks pretty common so we should have hit this problem before.

This point confused me also. It seems the code has been here for long time.
Anyway, if you think it is the right fix, i can send out a formal patch.

Yes, I think this shold be done.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Second question is that what's the purpose of eoi_pirq in startup_irq?

When we are actually creating new pirq we want to make sure there are no pending interrupts left over from previous use of the pirq.

If interrupt raise just before eoi_pirq in startup_irq, we might face the same issue? Can we make sure pirq is clean when do binding?

I rather think that

        unmask_evtchn(evtchn);
        eoi_pirq(irq_get_irq_data(irq));

in __startup_pirq() should be swapped.

-boris

Quoted 28 lines

Thx -
Shuo

Quoted 24 lines

-boris

Quoted 21 lines

BTW, i can resolve my problem by below patch. Does it make sence?

---
drivers/xen/events/events_base.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/events/events_base.c +1 -1
index 4bf7a34..341c456 100644
@@ -582,7 +582,7 @@ static void shutdown_pirq(struct irq_data *data)
 
 static void enable_pirq(struct irq_data *data)
 {
-    startup_pirq(data);
+    enable_dynirq(data);
 }
 
 static void disable_pirq(struct irq_data *data)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 28 lines · Boris Ostrovsky
Quoted 27 lines · On 07/27/2017 09:25 PM, [email protected] wrote:
Quoted 2 lines · Boris Ostrovsky

(Adjusting addressees: David is no longer maintaining Xen code, Juergen is)

Thanks Boris.

Quoted 23 lines · On 07/27/2017 09:04 AM, [email protected] wrote:
Quoted 20 lines

Hi,
Here is a device has xen-pirq-MSI interrupt. I found dom0 might lost interrupt during driver irq_disable/irq_enable.
There is a pair of irq_disable/enable in driver. Here is the scenario,
1. irq_disable(dev_irq) -> disable_dynirq -> mask_evtchn(dev_irq
channel)
2. dev interrupt raised by HW and Xen mark its evtchn as *pending*
status.
3. irq_enable(dev_irq) -> startup_pirq -> eoi_pirq ->

    clear_evtchn(channel of dev_irq) -> clear *pending* status

4. consume_one_event process the dev irq event without pending bit
assert
which result in interrupt lost once.
5. No HW interrupt raising anymore.

The first question here is why using startup_irq for .irq_enable rather than
enable_dynirq ? startup_irq will do eoi_pirq who clear the mask bit and pending
bit of the channel while enable_dynirq just only unmask the channel.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Seems like enable_dynirq() would indeed be the right choice. What is a bit strange is that scenario that you are describing looks pretty common so we should have hit this problem before.

This point confused me also. It seems the code has been here for long time.
Anyway, if you think it is the right fix, i can send out a formal patch.

Yes, I think this shold be done.

OK, will do.

Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Second question is that what's the purpose of eoi_pirq in startup_irq?

When we are actually creating new pirq we want to make sure there are no pending interrupts left over from previous use of the pirq.

If interrupt raise just before eoi_pirq in startup_irq, we might face the same issue? Can we make sure pirq is clean when do binding?

Quoted 7 lines

I rather think that

       unmask_evtchn(evtchn);
       eoi_pirq(irq_get_irq_data(irq));

in __startup_pirq() should be swapped.

I agree. It should be good for new pirq setup.

Quoted 32 lines

-boris

Quoted 28 lines

Thx -
Shuo

Quoted 24 lines

-boris

Quoted 21 lines

BTW, i can resolve my problem by below patch. Does it make sence?

---
drivers/xen/events/events_base.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/events/events_base.c +1 -1
index 4bf7a34..341c456 100644
@@ -582,7 +582,7 @@ static void shutdown_pirq(struct irq_data *data)
 
 static void enable_pirq(struct irq_data *data)
 {
-    startup_pirq(data);
+    enable_dynirq(data);
 }
 
 static void disable_pirq(struct irq_data *data)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel