From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA51817731 for ; Wed, 9 Aug 2023 11:07:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 584A0C433C8; Wed, 9 Aug 2023 11:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691579274; bh=0uoQadGXqKg72MEMLeUI1ip4qqlU8NKMsNuFi3rjqA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eRb+NVgCTG0nsvFXLn+2XVZIgxiWK+ExcN9WDUfxIt3caw7LNp2vSK3rNiYEPPKxm FM4G9b6lzA+V5cZbq+K6phXxmo77nlXL5FJRqaqQOysztZcfAg/8QS1zcwZDUowHbR 7xQ8keGsXneqtldVAaqhGnb07DGtmjX72tG96UTk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Lorenzo Pieralisi , Bjorn Helgaas , Manivannan Sadhasivam Subject: [PATCH 4.14 109/204] misc: pci_endpoint_test: Re-init completion for every test Date: Wed, 9 Aug 2023 12:40:47 +0200 Message-ID: <20230809103646.252544785@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809103642.552405807@linuxfoundation.org> References: <20230809103642.552405807@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Damien Le Moal commit fb620ae73b70c2f57b9d3e911fc24c024ba2324f upstream. 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. Link: https://lore.kernel.org/r/20230415023542.77601-16-dlemoal@kernel.org Fixes: 2c156ac71c6b ("misc: Add host side PCI driver for PCI test function device") Signed-off-by: Damien Le Moal Signed-off-by: Lorenzo Pieralisi Signed-off-by: Bjorn Helgaas Reviewed-by: Manivannan Sadhasivam Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -425,6 +425,10 @@ static long pci_endpoint_test_ioctl(stru struct pci_endpoint_test *test = to_endpoint_test(file->private_data); mutex_lock(&test->mutex); + + reinit_completion(&test->irq_raised); + test->last_irq = -ENODATA; + switch (cmd) { case PCITEST_BAR: bar = arg;