From patchwork Sat Apr 15 02:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13212286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95079C77B71 for ; Sat, 15 Apr 2023 02:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230251AbjDOCgY (ORCPT ); Fri, 14 Apr 2023 22:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjDOCgU (ORCPT ); Fri, 14 Apr 2023 22:36:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5863765B7 for ; Fri, 14 Apr 2023 19:36:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2FFE3640A5 for ; Sat, 15 Apr 2023 02:36:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34FAAC433A0; Sat, 15 Apr 2023 02:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681526173; bh=Ux2mNoqjhFXFx6wF6g7wcbT2X5pIm7bpvZRZPLuKCBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p2fbr+l5DWI9lxnbOZ6hJMi3sqo2w9yX9ycsRALciYL2A+rFqH5WCb+bfnEJt18Vz S5yuEozwbwKCflYrDYoONvtHQGwUZCYe0zhUKWL/Gn0iWHbmTATDkM4hwnV6DBzI37 G9+seRlt5/gnbNRjMMduY5VL3ch1CNtXjEhL/02DcWA2+0QvrOAG8Av+LKggWk0SvX fE/MpYIozolWIAoasGwihz6viFj2DNqi7K4Z3uJb6bjSpaWqyetqGv44kMNb+nnZto 6AmznPz6ioilgbv6MEaIWo3FWnVYesarHNJ8djCLjkUJZIHoJQrJyGpkfAQ8YBKyEe 6b8/SlvEzcudg== From: Damien Le Moal To: Bjorn Helgaas , linux-pci@vger.kernel.org Cc: Rick Wertenbroek , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH v5 16/17] misc: pci_endpoint_test: Do not write status in IRQ handler Date: Sat, 15 Apr 2023 11:35:41 +0900 Message-Id: <20230415023542.77601-17-dlemoal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230415023542.77601-1-dlemoal@kernel.org> References: <20230415023542.77601-1-dlemoal@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pci_endpoint_test_irqhandler() always rewrites the status register when an IRQ is raised, either as-is if STATUS_IRQ_RAISED is not set, or with STATUS_IRQ_RAISED cleared if that flag is set. The first case creates a race window with the endpoint side, meaning that the host side test driver may end up reading what it just wrote, thus losing the real status as set by the endpoint side before raising the next interrupt. This can prevent detecting that the STATUS_IRQ_RAISED flag was set by the endpoint. Remove this race window by not clearing the STATUS_IRQ_RAISED status flag and not rewriting that register for every IRQ received. Signed-off-by: Damien Le Moal Reviewed-by: Manivannan Sadhasivam --- drivers/misc/pci_endpoint_test.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 24efe3b88a1f..afd2577261f8 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -159,10 +159,7 @@ 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); - reg &= ~STATUS_IRQ_RAISED; } - pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS, - reg); return IRQ_HANDLED; }