diff mbox series

[10/12] misc: pci_endpoint_test: Re-init completion for every test

Message ID 20230215032155.74993-11-damien.lemoal@opensource.wdc.com (mailing list archive)
State Superseded
Headers show
Series PCI endpoint fixes and improvements | expand

Commit Message

Damien Le Moal Feb. 15, 2023, 3:21 a.m. UTC
The irq_raised completion used to detect the end of a test case is
initialized when the test device is probed, but never reinitialized
again before a test case. As a result, the irq_raised completion
synchronization is effective only for the first ioctl test case
executed. Any subsequent call to wait_for_completion() by another
ioctl() call will immediately return, potentially too early, leading to
false positive failures.

Fix this by reinitializing the irq_raised completion before starting a
new ioctl() test command.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/misc/pci_endpoint_test.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Manivannan Sadhasivam Feb. 16, 2023, 10:55 a.m. UTC | #1
On Wed, Feb 15, 2023 at 12:21:53PM +0900, Damien Le Moal wrote:
> The irq_raised completion used to detect the end of a test case is
> initialized when the test device is probed, but never reinitialized
> again before a test case. As a result, the irq_raised completion
> synchronization is effective only for the first ioctl test case
> executed. Any subsequent call to wait_for_completion() by another
> ioctl() call will immediately return, potentially too early, leading to
> false positive failures.
> 
> Fix this by reinitializing the irq_raised completion before starting a
> new ioctl() test command.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

Fixes tag? CC stable?

> ---
>  drivers/misc/pci_endpoint_test.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> index c1370950c79d..baab08f983a2 100644
> --- a/drivers/misc/pci_endpoint_test.c
> +++ b/drivers/misc/pci_endpoint_test.c
> @@ -725,6 +725,10 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
>  	struct pci_dev *pdev = test->pdev;
>  
>  	mutex_lock(&test->mutex);
> +
> +	reinit_completion(&test->irq_raised);
> +	test->last_irq = -1;

-ENODATA?

Thanks,
Mani

> +
>  	switch (cmd) {
>  	case PCITEST_BAR:
>  		bar = arg;
> -- 
> 2.39.1
>
Damien Le Moal Feb. 16, 2023, 12:35 p.m. UTC | #2
On 2/16/23 19:55, Manivannan Sadhasivam wrote:
> On Wed, Feb 15, 2023 at 12:21:53PM +0900, Damien Le Moal wrote:
>> The irq_raised completion used to detect the end of a test case is
>> initialized when the test device is probed, but never reinitialized
>> again before a test case. As a result, the irq_raised completion
>> synchronization is effective only for the first ioctl test case
>> executed. Any subsequent call to wait_for_completion() by another
>> ioctl() call will immediately return, potentially too early, leading to
>> false positive failures.
>>
>> Fix this by reinitializing the irq_raised completion before starting a
>> new ioctl() test command.
>>
>> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> 
> Fixes tag? CC stable?

I could not find a ref for this one... git blame did not lead to anything. Not
sure if this file was renamed in the past or something.

> 
>> ---
>>  drivers/misc/pci_endpoint_test.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
>> index c1370950c79d..baab08f983a2 100644
>> --- a/drivers/misc/pci_endpoint_test.c
>> +++ b/drivers/misc/pci_endpoint_test.c
>> @@ -725,6 +725,10 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
>>  	struct pci_dev *pdev = test->pdev;
>>  
>>  	mutex_lock(&test->mutex);
>> +
>> +	reinit_completion(&test->irq_raised);
>> +	test->last_irq = -1;
> 
> -ENODATA?

Sure. Anything works here.
diff mbox series

Patch

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index c1370950c79d..baab08f983a2 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -725,6 +725,10 @@  static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
 	struct pci_dev *pdev = test->pdev;
 
 	mutex_lock(&test->mutex);
+
+	reinit_completion(&test->irq_raised);
+	test->last_irq = -1;
+
 	switch (cmd) {
 	case PCITEST_BAR:
 		bar = arg;