From: Shunsuke Mie <mie@igel.co.jp>
To: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: "Vinod Koul" <vkoul@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Shunsuke Mie" <mie@igel.co.jp>,
"Kunihiko Hayashi" <hayashi.kunihiko@socionext.com>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Frank Li" <Frank.Li@nxp.com>,
linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
linux-pci@vger.kernel.org
Subject: [RFC PATCH 08/11] misc: pci_endpoint_test: Support a test of continuous transfer
Date: Fri, 17 Mar 2023 20:32:35 +0900 [thread overview]
Message-ID: <20230317113238.142970-9-mie@igel.co.jp> (raw)
In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp>
Add a `count` parameter that indicates a number of transfer continuously in
a test. Buffers for the test will be allocated with a size equal to size *
count, and passed address of the buffer to epf-test.
Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
---
drivers/misc/pci_endpoint_test.c | 60 +++++++++++++++++---------------
include/uapi/linux/pcitest.h | 1 +
2 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index d4a42e9ab86a..a49303f8c987 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -302,7 +302,7 @@ static int pci_endpoint_test_validate_xfer_params(struct device *dev,
return -EINVAL;
}
- if (param->size > SIZE_MAX - alignment) {
+ if (param->size * param->count > SIZE_MAX - alignment) {
dev_dbg(dev, "Maximum transfer data size exceeded\n");
return -EINVAL;
}
@@ -323,7 +323,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
void *src_addr;
void *dst_addr;
u32 flags = 0;
- size_t size;
+ size_t xfer_size;
dma_addr_t src_phys_addr;
dma_addr_t dst_phys_addr;
struct pci_dev *pdev = test->pdev;
@@ -349,21 +349,22 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
if (err)
return false;
- size = param.size;
+ xfer_size = param.size * param.count;
if (param.flags & PCITEST_FLAGS_USE_DMA)
flags |= FLAG_USE_DMA;
- orig_src_addr = kzalloc(size + alignment, GFP_KERNEL);
+
+ orig_src_addr = kzalloc(xfer_size + alignment, GFP_KERNEL);
if (!orig_src_addr) {
dev_err(dev, "Failed to allocate source buffer\n");
ret = false;
goto err;
}
- get_random_bytes(orig_src_addr, size + alignment);
+ get_random_bytes(orig_src_addr, xfer_size + alignment);
orig_src_phys_addr = dma_map_single(dev, orig_src_addr,
- size + alignment, DMA_TO_DEVICE);
+ xfer_size + alignment, DMA_TO_DEVICE);
if (dma_mapping_error(dev, orig_src_phys_addr)) {
dev_err(dev, "failed to map source buffer address\n");
ret = false;
@@ -385,9 +386,9 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_SRC_ADDR,
upper_32_bits(src_phys_addr));
- src_crc32 = crc32_le(~0, src_addr, size);
+ src_crc32 = crc32_le(~0, src_addr, xfer_size);
- orig_dst_addr = kzalloc(size + alignment, GFP_KERNEL);
+ orig_dst_addr = kzalloc(xfer_size + alignment, GFP_KERNEL);
if (!orig_dst_addr) {
dev_err(dev, "Failed to allocate destination address\n");
ret = false;
@@ -395,7 +396,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
}
orig_dst_phys_addr = dma_map_single(dev, orig_dst_addr,
- size + alignment, DMA_FROM_DEVICE);
+ xfer_size + alignment, DMA_FROM_DEVICE);
if (dma_mapping_error(dev, orig_dst_phys_addr)) {
dev_err(dev, "failed to map destination buffer address\n");
ret = false;
@@ -417,7 +418,8 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
upper_32_bits(dst_phys_addr));
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE,
- size);
+ param.size);
+ pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COUNT, param.count);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
@@ -427,10 +429,10 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
wait_for_completion(&test->irq_raised);
- dma_unmap_single(dev, orig_dst_phys_addr, size + alignment,
+ dma_unmap_single(dev, orig_dst_phys_addr, xfer_size + alignment,
DMA_FROM_DEVICE);
- dst_crc32 = crc32_le(~0, dst_addr, size);
+ dst_crc32 = crc32_le(~0, dst_addr, xfer_size);
if (dst_crc32 == src_crc32)
ret = true;
@@ -438,7 +440,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
kfree(orig_dst_addr);
err_dst_addr:
- dma_unmap_single(dev, orig_src_phys_addr, size + alignment,
+ dma_unmap_single(dev, orig_src_phys_addr, xfer_size + alignment,
DMA_TO_DEVICE);
err_src_phys_addr:
@@ -464,7 +466,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test,
size_t offset;
size_t alignment = test->alignment;
int irq_type = test->irq_type;
- size_t size;
+ size_t xfer_size;
u32 crc32;
int err;
@@ -478,21 +480,21 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test,
if (err)
return false;
- size = param.size;
+ xfer_size = param.size * param.count;
if (param.flags & PCITEST_FLAGS_USE_DMA)
flags |= FLAG_USE_DMA;
- orig_addr = kzalloc(size + alignment, GFP_KERNEL);
+ orig_addr = kzalloc(xfer_size + alignment, GFP_KERNEL);
if (!orig_addr) {
dev_err(dev, "Failed to allocate address\n");
ret = false;
goto err;
}
- get_random_bytes(orig_addr, size + alignment);
+ get_random_bytes(orig_addr, xfer_size + alignment);
- orig_phys_addr = dma_map_single(dev, orig_addr, size + alignment,
+ orig_phys_addr = dma_map_single(dev, orig_addr, xfer_size + alignment,
DMA_TO_DEVICE);
if (dma_mapping_error(dev, orig_phys_addr)) {
dev_err(dev, "failed to map source buffer address\n");
@@ -509,7 +511,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test,
addr = orig_addr;
}
- crc32 = crc32_le(~0, addr, size);
+ crc32 = crc32_le(~0, addr, xfer_size);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_CHECKSUM,
crc32);
@@ -518,7 +520,8 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test,
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_SRC_ADDR,
upper_32_bits(phys_addr));
- pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size);
+ pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, param.size);
+ pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COUNT, param.count);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
@@ -532,7 +535,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test,
if (reg & STATUS_READ_SUCCESS)
ret = true;
- dma_unmap_single(dev, orig_phys_addr, size + alignment,
+ dma_unmap_single(dev, orig_phys_addr, xfer_size + alignment,
DMA_TO_DEVICE);
err_phys_addr:
@@ -548,7 +551,7 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test,
struct pci_endpoint_test_xfer_param param;
bool ret = false;
u32 flags = 0;
- size_t size;
+ size_t xfer_size;
void *addr;
dma_addr_t phys_addr;
struct pci_dev *pdev = test->pdev;
@@ -571,19 +574,19 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test,
if (err)
return false;
- size = param.size;
+ xfer_size = param.size * param.count;
if (param.flags & PCITEST_FLAGS_USE_DMA)
flags |= FLAG_USE_DMA;
- orig_addr = kzalloc(size + alignment, GFP_KERNEL);
+ orig_addr = kzalloc(xfer_size + alignment, GFP_KERNEL);
if (!orig_addr) {
dev_err(dev, "Failed to allocate destination address\n");
ret = false;
goto err;
}
- orig_phys_addr = dma_map_single(dev, orig_addr, size + alignment,
+ orig_phys_addr = dma_map_single(dev, orig_addr, xfer_size + alignment,
DMA_FROM_DEVICE);
if (dma_mapping_error(dev, orig_phys_addr)) {
dev_err(dev, "failed to map source buffer address\n");
@@ -605,7 +608,8 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test,
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_DST_ADDR,
upper_32_bits(phys_addr));
- pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size);
+ pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, param.size);
+ pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COUNT, param.count);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags);
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
@@ -615,10 +619,10 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test,
wait_for_completion(&test->irq_raised);
- dma_unmap_single(dev, orig_phys_addr, size + alignment,
+ dma_unmap_single(dev, orig_phys_addr, xfer_size + alignment,
DMA_FROM_DEVICE);
- crc32 = crc32_le(~0, addr, size);
+ crc32 = crc32_le(~0, addr, xfer_size);
if (crc32 == pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CHECKSUM))
ret = true;
diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h
index f9c1af8d141b..8f05df4f95a6 100644
--- a/include/uapi/linux/pcitest.h
+++ b/include/uapi/linux/pcitest.h
@@ -25,6 +25,7 @@
struct pci_endpoint_test_xfer_param {
unsigned long size;
+ unsigned long count;
unsigned char flags;
};
--
2.25.1
next prev parent reply other threads:[~2023-03-17 11:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 11:32 [RFC PATCH 00/11] Introduce a test for continuous transfer Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 01/11] misc: pci_endpoint_test: Aggregate irq_type checking Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 02/11] misc: pci_endpoint_test: Remove an unused variable Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 03/11] pci: endpoint: function/pci-epf-test: Unify a range of time measurement Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 04/11] PCI: endpoint: functions/pci-epf-test: Move common difinitions to header file Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 05/11] MAINTAINERS: Add a header file for pci-epf-test Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 06/11] misc: pci_endpoint_test: Use a common header file between endpoint driver Shunsuke Mie
2023-03-17 14:47 ` [EXT] " Frank Li
2023-04-04 10:11 ` Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 07/11] PCI: endpoint: functions/pci-epf-test: Extend the test for continuous transfers Shunsuke Mie
2023-03-17 11:32 ` Shunsuke Mie [this message]
2023-03-17 11:32 ` [RFC PATCH 09/11] tools: PCI: Add 'C' option to support continuous transfer Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 10/11] dmaengine: dw-edma: Fix to change for " Shunsuke Mie
2023-03-17 11:32 ` [RFC PATCH 11/11] dmaengine: dw-edma: Fix to enable to issue dma request on DMA processing Shunsuke Mie
2023-03-31 5:38 ` [RFC PATCH 00/11] Introduce a test for continuous transfer Manivannan Sadhasivam
2023-04-04 9:57 ` Shunsuke Mie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230317113238.142970-9-mie@igel.co.jp \
--to=mie@igel.co.jp \
--cc=Frank.Li@nxp.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=dmaengine@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo.pimentel@synopsys.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=vkoul@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox