[PATCH] misc: pci_endpoint_test: Add WARN_ON() to detect broken EPC drivers
Niklas Cassel <[email protected]>
| Newsgroups | org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
Getting two IRQs when we are only expecting a single IRQ is a very serious error, and suggests that something is very wrong in the EPC driver. Scream loudly so that EPC driver developers can see the problem, which might otherwise be very hard to detect. Signed-off-by: Niklas Cassel <[email protected]> --- drivers/misc/pci_endpoint_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 3635741c3e7a..a212e53654c6 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -178,6 +178,19 @@ static irqreturn_t pci_endpoint_test_irqhandler(int irq, void *dev_id) if (reg & STATUS_IRQ_RAISED) { test->last_irq = irq; complete(&test->irq_raised); + /* + * The endpoint test driver performs all testing sequentially. + * This means that test->irq_raised.done should never exceed 1. + * If it does, then we received two IRQs in a row, without a + * successful wait_for_completion_timeout() call in between. + * + * While complete() increases test->irq_raised.done by one, + * wait_for_completion_timeout() reduces test->irq_raised.done + * by one on success. + * + * Please debug your EPC driver if you see this warning. + */ + WARN_ON(test->irq_raised.done > 1); } return IRQ_HANDLED; -- 2.55.0