From patchwork Tue Mar 18 10:33:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 14020760 X-Patchwork-Delegate: kw@linux.com 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 BBED9202997 for ; Tue, 18 Mar 2025 10:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294083; cv=none; b=Hc+Cccj2cOo1VEsvCIyISF/RuydlpvwM020Y3LsQnkYtW7e9wJMZ0mR5gn9ZL0Vp+euGkpjX90OVQR0Ef4UDwXFIXvXweFYLHscshubWXmByfA2DszlUXHaSPpMYijZ9uzJmZseAg0rUykYFD9i5kWlQfmlOgmt+RlfN/P+SDQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294083; c=relaxed/simple; bh=3voIixtwLTFprMVAMuattwaiVxrglfzHdTdJ4WNeJTw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rjwvsctuTFebJmWqklW/INIs1ihai+l0cMi985eZvE01iGVrhgpL5owkoQRzfl9FCe5B5fGwZxtEJBpYdnHV1lkjkfMbDM5ocuSHzuy2cNm9G2dXuKr/JQ5Zebe/5+T9fiW6PdaXlPXrwkV71PxxoihGJ+eigtv84MtQAzYjBP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GlApfd5N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GlApfd5N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB16DC4CEE3; Tue, 18 Mar 2025 10:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742294083; bh=3voIixtwLTFprMVAMuattwaiVxrglfzHdTdJ4WNeJTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlApfd5NJQU2aa5510/raBMqsLiX4hWAgdGYkXNP20oEgyuRpHDlsPC91KWlMXdTQ hbhJP+2gOMajRJ85CQI2AmhQ3NKgb92DBT/uaEuzYIqeUyh7DuYi/2ewOEyAKV4pgF Cmu8LFzgIqCb89OnhLIv/hE0Y5YuHoRT/pJ9iXnmuIYJfmkZu/lDq2TUgHVGB/42tz Z5W367QgcQMoWVwx+0WdaWRsj358AnzjR/tFo5g7haItO4xPFg+sSTGOKyxOqubiyj cVBNGufsr9/7iU5inWf9ODkxCIGWInDhWufFzNG3woTzFg/dNaUNyAtTvp05/g8G3b pd1UdJe6dxvNQ== From: Niklas Cassel To: bhelgaas@google.com, kw@linux.com, manivannan.sadhasivam@linaro.org Cc: linux-pci@vger.kernel.org, Damien Le Moal , Kunihiko Hayashi , Niklas Cassel Subject: [PATCH 1/4] Revert "misc: pci_endpoint_test: Add support for PCITEST_IRQ_TYPE_AUTO" Date: Tue, 18 Mar 2025 11:33:32 +0100 Message-ID: <20250318103330.1840678-7-cassel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318103330.1840678-6-cassel@kernel.org> References: <20250318103330.1840678-6-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4703; i=cassel@kernel.org; h=from:subject; bh=3voIixtwLTFprMVAMuattwaiVxrglfzHdTdJ4WNeJTw=; b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGNJvev97MGON55sn29M4Hmd7L/t+k5VfYafGXG6+n9Z2h V8KfU2XdpSyMIhxMciKKbL4/nDZX9ztPuW44h0bmDmsTCBDGLg4BWAiSV0M/1O1px1IPTXn2rJ1 +1lviZ5jFXzw+LvcMpOmjY+zQud3XEli+O/D0HydubHF9vuy0FLBmzMiPlotvZW0vd5Dcf5S7/N xLZwA X-Developer-Key: i=cassel@kernel.org; a=openpgp; fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA This reverts commit c4aaa6b5b5ac14ea9b0abf1e0f4bf24c332a9b34. The PCI endpoint maintainer did not like PCITEST_IRQ_TYPE_AUTO, so let's remove this IRQ type and rework the implementation. Signed-off-by: Niklas Cassel --- Hello PCI maintainers, feel free to squash / drop the original commit from the branch. drivers/misc/pci_endpoint_test.c | 25 ++++--------------- include/uapi/linux/pcitest.h | 1 - .../pci_endpoint/pci_endpoint_test.c | 12 ++++----- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index d294850a35a12..849d730ba14dd 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -66,9 +66,6 @@ #define PCI_ENDPOINT_TEST_CAPS 0x30 #define CAP_UNALIGNED_ACCESS BIT(0) -#define CAP_MSI BIT(1) -#define CAP_MSIX BIT(2) -#define CAP_INTX BIT(3) #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f @@ -115,7 +112,6 @@ struct pci_endpoint_test { struct miscdevice miscdev; enum pci_barno test_reg_bar; size_t alignment; - u32 ep_caps; const char *name; }; @@ -806,23 +802,11 @@ static int pci_endpoint_test_set_irq(struct pci_endpoint_test *test, int ret; if (req_irq_type < PCITEST_IRQ_TYPE_INTX || - req_irq_type > PCITEST_IRQ_TYPE_AUTO) { + req_irq_type > PCITEST_IRQ_TYPE_MSIX) { dev_err(dev, "Invalid IRQ type option\n"); return -EINVAL; } - if (req_irq_type == PCITEST_IRQ_TYPE_AUTO) { - if (test->ep_caps & CAP_MSI) - req_irq_type = PCITEST_IRQ_TYPE_MSI; - else if (test->ep_caps & CAP_MSIX) - req_irq_type = PCITEST_IRQ_TYPE_MSIX; - else if (test->ep_caps & CAP_INTX) - req_irq_type = PCITEST_IRQ_TYPE_INTX; - else - /* fallback to MSI if no caps defined */ - req_irq_type = PCITEST_IRQ_TYPE_MSI; - } - if (test->irq_type == req_irq_type) return 0; @@ -908,12 +892,13 @@ static void pci_endpoint_test_get_capabilities(struct pci_endpoint_test *test) { struct pci_dev *pdev = test->pdev; struct device *dev = &pdev->dev; + u32 caps; - test->ep_caps = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CAPS); - dev_dbg(dev, "PCI_ENDPOINT_TEST_CAPS: %#x\n", test->ep_caps); + caps = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CAPS); + dev_dbg(dev, "PCI_ENDPOINT_TEST_CAPS: %#x\n", caps); /* CAP_UNALIGNED_ACCESS is set if the EP can do unaligned access */ - if (test->ep_caps & CAP_UNALIGNED_ACCESS) + if (caps & CAP_UNALIGNED_ACCESS) test->alignment = 0; } diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index d3aa8715a525e..304bf9be0f9a0 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -27,7 +27,6 @@ #define PCITEST_IRQ_TYPE_INTX 0 #define PCITEST_IRQ_TYPE_MSI 1 #define PCITEST_IRQ_TYPE_MSIX 2 -#define PCITEST_IRQ_TYPE_AUTO 3 #define PCITEST_FLAGS_USE_DMA 0x00000001 diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index ac26481d29d9d..fdf4bc6aa9d2a 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -181,8 +181,8 @@ TEST_F(pci_ep_data_transfer, READ_TEST) if (variant->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; - pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO); - ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type"); + pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_MSI); + ASSERT_EQ(0, ret) TH_LOG("Can't set MSI IRQ type"); for (i = 0; i < ARRAY_SIZE(test_size); i++) { param.size = test_size[i]; @@ -200,8 +200,8 @@ TEST_F(pci_ep_data_transfer, WRITE_TEST) if (variant->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; - pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO); - ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type"); + pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_MSI); + ASSERT_EQ(0, ret) TH_LOG("Can't set MSI IRQ type"); for (i = 0; i < ARRAY_SIZE(test_size); i++) { param.size = test_size[i]; @@ -219,8 +219,8 @@ TEST_F(pci_ep_data_transfer, COPY_TEST) if (variant->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; - pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO); - ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type"); + pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_MSI); + ASSERT_EQ(0, ret) TH_LOG("Can't set MSI IRQ type"); for (i = 0; i < ARRAY_SIZE(test_size); i++) { param.size = test_size[i]; From patchwork Tue Mar 18 10:33:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 14020761 X-Patchwork-Delegate: kw@linux.com 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 B127E202997 for ; Tue, 18 Mar 2025 10:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294085; cv=none; b=pGpunpPIjRT44aGF+LR4o5Q5mXZcwX0dDYvMrTyeNtDTFzmHamqOfd2rUp4KxJed6Icarf4v2CZPlRSKqR11FYardo4dYtgcJtbY80TtujrMg75R9EoHQREc4CwOwy42petWpS87eV959xTsglQEJWDZBbD9MR0ZaqMdr0D/zb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294085; c=relaxed/simple; bh=vWFbYZ4X7nT2H0Gc1jZ4SL8M29/PajaJvftiDxaBDr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SOOVd+Qv8Tsy0eyIESfnNUwU/8a6wOHV61xacJOl1U58QRZYe4C0HKygfBcWbEBFj2SkcZxOG/byFfZnUDu7n9l5eTE0Yf+KKyPdcsnW8jHjunKzlQ11p3P088/EBakGwxttdIu+lyDG0/ru1AKCZsNdOFVH4X9tJSohjihHz4Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MngzIVoH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MngzIVoH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACDB5C4CEEE; Tue, 18 Mar 2025 10:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742294085; bh=vWFbYZ4X7nT2H0Gc1jZ4SL8M29/PajaJvftiDxaBDr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MngzIVoHxqVQFjyY4Ty9x9V3vLytdgbPhwJZbq1ALifMVNdHmLRBEzGg4fpsO2BW9 2oisLRm39SfzbITnLZHuhQxO17/DH3UrJZOMQ/z92QsUBZKNdwlzw8jk+0hMNbsYze iU1SLOECAe6iluU3hXZTeb5pEmt2iRQwj/s2M7/lXV9mIXNKGR3iaxX8jQJnaFqbqg YFU+toVHRUX94K47CZp0eNEXXz5/teGduhemf8FGamsts7XsEhjxBhGr4INLzTqCyc 0a3Um2SKhpUN5kAS32oaKoS/dPACcQxBSGVQ3Lf8iwUPZzBD7gf5lrXhWpDTV0dqd2 rIn5IsRr7tZFg== From: Niklas Cassel To: bhelgaas@google.com, kw@linux.com, manivannan.sadhasivam@linaro.org Cc: linux-pci@vger.kernel.org, Damien Le Moal , Kunihiko Hayashi , Niklas Cassel Subject: [PATCH 2/4] misc: pci_endpoint_test: Fetch supported IRQ types in CAPS register Date: Tue, 18 Mar 2025 11:33:33 +0100 Message-ID: <20250318103330.1840678-8-cassel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318103330.1840678-6-cassel@kernel.org> References: <20250318103330.1840678-6-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1623; i=cassel@kernel.org; h=from:subject; bh=vWFbYZ4X7nT2H0Gc1jZ4SL8M29/PajaJvftiDxaBDr0=; b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGNJvev/b+3Dx3+X/2NM33y2czb3pTwjr3ntaFjkKZ7btP h/HHbCtuKOUhUGMi0FWTJHF94fL/uJu9ynHFe/YwMxhZQIZwsDFKQATeVjJyPC/4uBBLe9DWk02 HNcV3Q6GH+bg8chuK73ZV5il9iUpvZ2R4djnPJeCzdk8updLPt5sK/WboyLn3Hsm2ePRvMUfGc/ +ZwQA X-Developer-Key: i=cassel@kernel.org; a=openpgp; fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA Fetch supported IRQ types in CAPS register and save them in struct pci_endpoint_test. The supported IRQ types will be used in follow-up commit. Signed-off-by: Niklas Cassel --- drivers/misc/pci_endpoint_test.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 849d730ba14dd..3c04121d24733 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -66,6 +66,9 @@ #define PCI_ENDPOINT_TEST_CAPS 0x30 #define CAP_UNALIGNED_ACCESS BIT(0) +#define CAP_MSI BIT(1) +#define CAP_MSIX BIT(2) +#define CAP_INTX BIT(3) #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f @@ -112,6 +115,7 @@ struct pci_endpoint_test { struct miscdevice miscdev; enum pci_barno test_reg_bar; size_t alignment; + u32 ep_caps; const char *name; }; @@ -892,13 +896,12 @@ static void pci_endpoint_test_get_capabilities(struct pci_endpoint_test *test) { struct pci_dev *pdev = test->pdev; struct device *dev = &pdev->dev; - u32 caps; - caps = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CAPS); - dev_dbg(dev, "PCI_ENDPOINT_TEST_CAPS: %#x\n", caps); + test->ep_caps = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CAPS); + dev_dbg(dev, "PCI_ENDPOINT_TEST_CAPS: %#x\n", test->ep_caps); /* CAP_UNALIGNED_ACCESS is set if the EP can do unaligned access */ - if (caps & CAP_UNALIGNED_ACCESS) + if (test->ep_caps & CAP_UNALIGNED_ACCESS) test->alignment = 0; } From patchwork Tue Mar 18 10:33:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 14020762 X-Patchwork-Delegate: kw@linux.com 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 CED0E202997 for ; Tue, 18 Mar 2025 10:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294087; cv=none; b=JfqymMo8Nbhj/zmMWkSH1o32LZ56dWRpCUyfsCqxBNOIoj+ip8BGIudaqM9SovjG/9WtCSyDyJNaGWagcBUFCDnj/DLz94nHbTK/zLfIPic3uPXmL2v1BWgQnGASfAzu/YDxxEBxf7MwVp4MJaWYdh6tSvTrLh+A071+nw1xEzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294087; c=relaxed/simple; bh=Wi/+WPCv9YnzjLMK4r8AZm+W8OVyqzF5D4rGYKI6VwQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LbVSgmE/A14zSe7y5NupPjX8qm9L0LBTgxUqJ3CZBbEJGRu1LLmPXnPfFm++sZeDJHzg0QcySqg2kWjqu9uFGfVx0Qz42wgP9ooGwkQU6GsnuwBoXbqSH/WvaPK22PAj5QDnGY4ghBLbFPyaYfT1rWbYd1ok7wfN2UihUS88KHk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=irY7L6qz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="irY7L6qz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADB36C4CEEF; Tue, 18 Mar 2025 10:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742294087; bh=Wi/+WPCv9YnzjLMK4r8AZm+W8OVyqzF5D4rGYKI6VwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=irY7L6qzzwuRilvJaKNtoxdl7NoBSXkGZA2GvsCwnxDtpup8rJFVU34WG/6m8puAq RLv4I8wPhpjmGDISbAz01vnZfNsR+NCznOb+7XiyezdP8TTon341RAz+l8qbjKtctG HnZvXQHaJKy2DVYeDoJL1KpmwSetyEp7AVGXeYWHDaGFJDbxmr6v5lNuFsrzpy7k5a eTBtdNh4x3slb6FA+3Ad0gbo1OlDA1tj+QFvyVry0P3tJEgEd6ySeh4sLjr1l5unDh WGmuV7ICXx0lTzEUXM54D/squGFNuVq3r1vfxI43lib8nw4hNb7lWtygsukBAvQYCE bNezlA2/mDkew== From: Niklas Cassel To: bhelgaas@google.com, kw@linux.com, manivannan.sadhasivam@linaro.org Cc: linux-pci@vger.kernel.org, Damien Le Moal , Kunihiko Hayashi , Niklas Cassel Subject: [PATCH 3/4] misc: pci_endpoint_test: Let PCITEST_{READ,WRITE,COPY} set IRQ type automatically Date: Tue, 18 Mar 2025 11:33:34 +0100 Message-ID: <20250318103330.1840678-9-cassel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318103330.1840678-6-cassel@kernel.org> References: <20250318103330.1840678-6-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6120; i=cassel@kernel.org; h=from:subject; bh=Wi/+WPCv9YnzjLMK4r8AZm+W8OVyqzF5D4rGYKI6VwQ=; b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGNJvev9r+jgtIGXecpOeCQvz1Ux1vBz6Zh57EVf6+u+hy jeRoVqsHaUsDGJcDLJiiiy+P1z2F3e7TzmueMcGZg4rE8gQBi5OAZjInXaGf9reW+bxpSytjP7l HK/AWLZKSSemOk1D3Z9z/1VZ5bNrChkZ5i4s/fbzZPVmG6Hu6P2Rr9k798Vde9/BUrBx1i8RZpU 33AA= X-Developer-Key: i=cassel@kernel.org; a=openpgp; fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA The test cases for read/write/copy currently do: 1) ioctl(PCITEST_SET_IRQTYPE, MSI) 2) ioctl(PCITEST_{READ,WRITE,COPY}) This design is quite bad for a few reasons: -It assumes that all PCI EPCs support MSI. -One ioctl should be sufficient for these test cases. Modify the PCITEST_{READ,WRITE,COPY} ioctls to set IRQ type automatically, overwriting the currently configured IRQ type. It there are no IRQ types supported in the CAPS register, fall back to MSI IRQs. This way the implementation is no worse than before this commit. Any test case that requires a specific IRQ type, e.g. MSIX_TEST, will do an explicit PCITEST_SET_IRQTYPE ioctl at the start of the test case, thus it is safe to always overwrite the configured IRQ type. Signed-off-by: Niklas Cassel --- drivers/misc/pci_endpoint_test.c | 126 +++++++++++++++++-------------- 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 3c04121d24733..cfaeeea7642ac 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -464,6 +464,62 @@ static int pci_endpoint_test_validate_xfer_params(struct device *dev, return 0; } +static int pci_endpoint_test_clear_irq(struct pci_endpoint_test *test) +{ + pci_endpoint_test_release_irq(test); + pci_endpoint_test_free_irq_vectors(test); + + return 0; +} + +static int pci_endpoint_test_set_irq(struct pci_endpoint_test *test, + int req_irq_type) +{ + struct pci_dev *pdev = test->pdev; + struct device *dev = &pdev->dev; + int ret; + + if (req_irq_type < PCITEST_IRQ_TYPE_INTX || + req_irq_type > PCITEST_IRQ_TYPE_MSIX) { + dev_err(dev, "Invalid IRQ type option\n"); + return -EINVAL; + } + + if (test->irq_type == req_irq_type) + return 0; + + pci_endpoint_test_release_irq(test); + pci_endpoint_test_free_irq_vectors(test); + + ret = pci_endpoint_test_alloc_irq_vectors(test, req_irq_type); + if (ret) + return ret; + + ret = pci_endpoint_test_request_irq(test); + if (ret) { + pci_endpoint_test_free_irq_vectors(test); + return ret; + } + + return 0; +} + +static int pci_endpoint_test_set_auto_irq(struct pci_endpoint_test *test, + int *irq_type) +{ + if (test->ep_caps & CAP_MSI) + *irq_type = PCITEST_IRQ_TYPE_MSI; + else if (test->ep_caps & CAP_MSIX) + *irq_type = PCITEST_IRQ_TYPE_MSIX; + else if (test->ep_caps & CAP_INTX) + *irq_type = PCITEST_IRQ_TYPE_INTX; + else + /* fallback to MSI if no caps defined */ + *irq_type = PCITEST_IRQ_TYPE_MSI; + + return pci_endpoint_test_set_irq(test, *irq_type); +} + static int pci_endpoint_test_copy(struct pci_endpoint_test *test, unsigned long arg) { @@ -483,7 +539,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test, dma_addr_t orig_dst_phys_addr; size_t offset; size_t alignment = test->alignment; - int irq_type = test->irq_type; + int irq_type; u32 src_crc32; u32 dst_crc32; int ret; @@ -504,11 +560,9 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test, if (use_dma) flags |= FLAG_USE_DMA; - if (irq_type < PCITEST_IRQ_TYPE_INTX || - irq_type > PCITEST_IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - return -EINVAL; - } + ret = pci_endpoint_test_set_auto_irq(test, &irq_type); + if (ret) + return ret; orig_src_addr = kzalloc(size + alignment, GFP_KERNEL); if (!orig_src_addr) { @@ -616,7 +670,7 @@ static int pci_endpoint_test_write(struct pci_endpoint_test *test, dma_addr_t orig_phys_addr; size_t offset; size_t alignment = test->alignment; - int irq_type = test->irq_type; + int irq_type; size_t size; u32 crc32; int ret; @@ -637,11 +691,9 @@ static int pci_endpoint_test_write(struct pci_endpoint_test *test, if (use_dma) flags |= FLAG_USE_DMA; - if (irq_type < PCITEST_IRQ_TYPE_INTX || - irq_type > PCITEST_IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - return -EINVAL; - } + ret = pci_endpoint_test_set_auto_irq(test, &irq_type); + if (ret) + return ret; orig_addr = kzalloc(size + alignment, GFP_KERNEL); if (!orig_addr) { @@ -714,7 +766,7 @@ static int pci_endpoint_test_read(struct pci_endpoint_test *test, dma_addr_t orig_phys_addr; size_t offset; size_t alignment = test->alignment; - int irq_type = test->irq_type; + int irq_type; u32 crc32; int ret; @@ -734,11 +786,9 @@ static int pci_endpoint_test_read(struct pci_endpoint_test *test, if (use_dma) flags |= FLAG_USE_DMA; - if (irq_type < PCITEST_IRQ_TYPE_INTX || - irq_type > PCITEST_IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - return -EINVAL; - } + ret = pci_endpoint_test_set_auto_irq(test, &irq_type); + if (ret) + return ret; orig_addr = kzalloc(size + alignment, GFP_KERNEL); if (!orig_addr) { @@ -790,46 +840,6 @@ static int pci_endpoint_test_read(struct pci_endpoint_test *test, return ret; } -static int pci_endpoint_test_clear_irq(struct pci_endpoint_test *test) -{ - pci_endpoint_test_release_irq(test); - pci_endpoint_test_free_irq_vectors(test); - - return 0; -} - -static int pci_endpoint_test_set_irq(struct pci_endpoint_test *test, - int req_irq_type) -{ - struct pci_dev *pdev = test->pdev; - struct device *dev = &pdev->dev; - int ret; - - if (req_irq_type < PCITEST_IRQ_TYPE_INTX || - req_irq_type > PCITEST_IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - return -EINVAL; - } - - if (test->irq_type == req_irq_type) - return 0; - - pci_endpoint_test_release_irq(test); - pci_endpoint_test_free_irq_vectors(test); - - ret = pci_endpoint_test_alloc_irq_vectors(test, req_irq_type); - if (ret) - return ret; - - ret = pci_endpoint_test_request_irq(test); - if (ret) { - pci_endpoint_test_free_irq_vectors(test); - return ret; - } - - return 0; -} - static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { From patchwork Tue Mar 18 10:33:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 14020763 X-Patchwork-Delegate: kw@linux.com 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 CF166202997 for ; Tue, 18 Mar 2025 10:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294089; cv=none; b=pG3W4LVIGLKPxaK6sMUx0j5thPKG+qbmtQLAUr1rrceruwEH1AbTg/YBG4kRSCje2ZtzMNjaaYwDLTsLWl/zCt4pq6K3XQ8ce3YNvudirRsBWMwXiRvdZ7oFesH8+4qdbrj/vI32xPQnJrY+xLc+3Dy9jmC2n2dhaB/dBs2fl1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294089; c=relaxed/simple; bh=EKdt3QSmiArJ8pbCm74mjgT16Ha4NGqGMBHjmTz/JvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lz0zq6X1db1ND6HhdLEShF/P18MTpdrlij2lncvWQE6z6q6B/adUI2YuijWSL883SOwCpRSxlF0bjOecIAtsEEXmWauvoDVhnLm7j7ryU0Si6Bel4lTSo/uLbNFjO9aorNTZz+DZ1vwVJ4K0L7+Z0CCzmlQFd9Z3FMqvEqRgrlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nh9jS0ou; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nh9jS0ou" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE2DAC4CEE3; Tue, 18 Mar 2025 10:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742294089; bh=EKdt3QSmiArJ8pbCm74mjgT16Ha4NGqGMBHjmTz/JvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nh9jS0ouxFkwvV2QQqGsVWU7Y+3VCN6CZycXAvirjOLMAXByGvXHOfG8YoUnm+xjw sVmQczKLeWKh2dfIrQi32w8kCOT1qiu4FQuSLjun03SE2o+hr6vIUjzDlsTbrADLPx ESoZMn9+smaERxJSR6oA7IaEc2vFIzdp63HAxsm2UWDoNlkFwo/vA3Tx7viblh2OFW iKBv8Ks9MmLUVkSOss2yAhGc51gLCArYh/eE6iiumxf8wFlJ9WuaSFsRgGKWPR11es JnkZPT6FRqhCKEi2SJ+gnu3cV/ePumS8ajmfh/0qaM1fstPzq+2F1FBMBuQOeRla9i +Z+4aEkBYS0Vg== From: Niklas Cassel To: bhelgaas@google.com, kw@linux.com, manivannan.sadhasivam@linaro.org Cc: linux-pci@vger.kernel.org, Damien Le Moal , Kunihiko Hayashi , Niklas Cassel Subject: [PATCH 4/4] selftests: pci_endpoint: Remove PCITEST_SET_IRQTYPE ioctls for read/write/copy Date: Tue, 18 Mar 2025 11:33:35 +0100 Message-ID: <20250318103330.1840678-10-cassel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318103330.1840678-6-cassel@kernel.org> References: <20250318103330.1840678-6-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2042; i=cassel@kernel.org; h=from:subject; bh=EKdt3QSmiArJ8pbCm74mjgT16Ha4NGqGMBHjmTz/JvA=; b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGNJvev//w1V74E5Ngn7S9UWTdr7zv7JCJcY1IlTytLLqc h+l2ydLOkpZGMS4GGTFFFl8f7jsL+52n3Jc8Y4NzBxWJpAhDFycAjCRjCJGhut7Jn2X8DmxK/au a+jvdKk4t8wpzy8Kb3yQtvzYzYu3GLgY/hdF312kY2Xy9Y8OW51A0qGFc/Iv8xb0+m/bcacr1J7 hBQcA X-Developer-Key: i=cassel@kernel.org; a=openpgp; fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA The test cases for read/write/copy currently do: 1) ioctl(PCITEST_SET_IRQTYPE) 2) ioctl(PCITEST_{READ,WRITE,COPY}) The PCITEST_{READ,WRITE,COPY} ioctls now configure the IRQ type to use themselves, ignoring any value configured by the user via ioctl(PCITEST_SET_IRQTYPE). Since PCITEST_{READ,WRITE,COPY} ioctls will ignore the IRQ type set by the user, remove the ioctl(PCITEST_SET_IRQTYPE), as it has no effect on the result of the test case. Signed-off-by: Niklas Cassel --- tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c index fdf4bc6aa9d2a..e788ab4eb003e 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -181,9 +181,6 @@ TEST_F(pci_ep_data_transfer, READ_TEST) if (variant->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; - pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_MSI); - ASSERT_EQ(0, ret) TH_LOG("Can't set MSI IRQ type"); - for (i = 0; i < ARRAY_SIZE(test_size); i++) { param.size = test_size[i]; pci_ep_ioctl(PCITEST_READ, ¶m); @@ -200,9 +197,6 @@ TEST_F(pci_ep_data_transfer, WRITE_TEST) if (variant->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; - pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_MSI); - ASSERT_EQ(0, ret) TH_LOG("Can't set MSI IRQ type"); - for (i = 0; i < ARRAY_SIZE(test_size); i++) { param.size = test_size[i]; pci_ep_ioctl(PCITEST_WRITE, ¶m); @@ -219,9 +213,6 @@ TEST_F(pci_ep_data_transfer, COPY_TEST) if (variant->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; - pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_MSI); - ASSERT_EQ(0, ret) TH_LOG("Can't set MSI IRQ type"); - for (i = 0; i < ARRAY_SIZE(test_size); i++) { param.size = test_size[i]; pci_ep_ioctl(PCITEST_COPY, ¶m);