From patchwork Fri Mar 17 11:32:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178926 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 2D63BC74A5B for ; Fri, 17 Mar 2023 11:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbjCQLcz (ORCPT ); Fri, 17 Mar 2023 07:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbjCQLcv (ORCPT ); Fri, 17 Mar 2023 07:32:51 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EBB250989 for ; Fri, 17 Mar 2023 04:32:49 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id e15-20020a17090ac20f00b0023d1b009f52so8778112pjt.2 for ; Fri, 17 Mar 2023 04:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bus/9rIf8WxfzN8ER9bYpWlzeg5Ck6oeY/WJO+0UvIw=; b=wjLLMPk3hLo+Z7RximKbN65/Qady7mVgH6NFCzRlaAFKfTTMXOleyIvUVgDUKtNTHW XkBRWU7Yv9qFYCjmMhymhPnGqU1Gnxb5CiMDgbMrJvjlzuGrIPrvsvwR5cxtlJugLZGV co+zUqq+4zivVXMhJQ2eAFvwU4LHD885bXe52uZW8+19bCkFrebHPaAmhHxnPmSw5ORZ bL3ahR5FRhuZLlebHQMI3fMZLylXZL56GdcJq+T1u6lLJNPggZr8uyQK9tYtqblglhnr ZtxRU4ZWLbCj+mVhFVJasDUeXkNzesGWDZYsWOnVXjG2T9Z0Fvu9UVtr0ESVenGwOKqz 5eTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bus/9rIf8WxfzN8ER9bYpWlzeg5Ck6oeY/WJO+0UvIw=; b=J4aOfIlSpilxIxFOlnf9tNQ4pbUKJHjs9PgbZdCBbNj5bvd0q0NbUHXo+QRlXC5lzg 2sV8KcmtZZ1bN2mQqIn3PHdTWGJ4ukHe3h1ZzmgIZcodDNpPa3JBVSSCIb8cAEx9itqM NniRfJU3ihU7g1Qus1LFon72lmOTVVpkKCPEW2C6SsK494xUMlafOI9/gjTfps1yqmHC C3UEvAK44WY50xV/MDpAm03Cj84cn1B0qwzoZbzKRDWAxjl2CX6WDNU6bUtyBb1hDwdq LQvEvdAKI5acxSWuQGCIEtOU0Dnv1hFQ3R2Q+ejv4zRyC8B7vdYT+seT9rx1rqb9hmYe JiRQ== X-Gm-Message-State: AO0yUKWCQ8Bvn6V5i7lejIk5rS2PoQ47VjSi7fMhVYmVj2ke7u/yzb7g 5Kys9xFXtlP98tftGwGpfTdBEA== X-Google-Smtp-Source: AK7set9ZWKEJMSeTL9s9Yx06FwGSd6i3KWMaGnzaDbwh0J+zPH2o47HFBT8jsfkU9nOpQ6sNvFqkcA== X-Received: by 2002:a17:902:d10c:b0:19c:a9bc:ce57 with SMTP id w12-20020a170902d10c00b0019ca9bcce57mr5454248plw.64.1679052768772; Fri, 17 Mar 2023 04:32:48 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:32:48 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 01/11] misc: pci_endpoint_test: Aggregate irq_type checking Date: Fri, 17 Mar 2023 20:32:28 +0900 Message-Id: <20230317113238.142970-2-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org There are the same checkings in each test, so merge the redundant checks. Signed-off-by: Shunsuke Mie --- drivers/misc/pci_endpoint_test.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 1d8f72b42c0a..22e0cc0b75d3 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -347,6 +347,11 @@ static int pci_endpoint_test_validate_xfer_params(struct device *dev, return -EINVAL; } + if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { + dev_dbg(dev, "Invalid IRQ type option\n"); + return -EINVAL; + } + return 0; } @@ -391,11 +396,6 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, if (use_dma) flags |= FLAG_USE_DMA; - if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - goto err; - } - orig_src_addr = kzalloc(size + alignment, GFP_KERNEL); if (!orig_src_addr) { dev_err(dev, "Failed to allocate source buffer\n"); @@ -527,11 +527,6 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, if (use_dma) flags |= FLAG_USE_DMA; - if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - goto err; - } - orig_addr = kzalloc(size + alignment, GFP_KERNEL); if (!orig_addr) { dev_err(dev, "Failed to allocate address\n"); @@ -627,11 +622,6 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, if (use_dma) flags |= FLAG_USE_DMA; - if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); - goto err; - } - orig_addr = kzalloc(size + alignment, GFP_KERNEL); if (!orig_addr) { dev_err(dev, "Failed to allocate destination address\n"); From patchwork Fri Mar 17 11:32:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178927 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 6808FC6FD1D for ; Fri, 17 Mar 2023 11:33:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjCQLdH (ORCPT ); Fri, 17 Mar 2023 07:33:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbjCQLc5 (ORCPT ); Fri, 17 Mar 2023 07:32:57 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25DC77CA5 for ; Fri, 17 Mar 2023 04:32:52 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id o11so4996700ple.1 for ; Fri, 17 Mar 2023 04:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052772; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8V+IWdBYw8MK5GfswCmGJSJSTT+akxzrw5rFlMbMC5w=; b=bTcKJztfGLfF3k9V/x7Kf+eP+33U7Lt8fKhkDY/tDXyqM0TKfAiuG6wZ+1Z9fcCMfV 21ZZchq+pkv5liRAR6nUWh0EmPeYqWykedKEgNBTKT/IaM/hqy1zewPwJQKZU9WTOhzn R3bcw82HmGvgtogR41uCE35FhpJs6vHAzNR0rnaCrDsntjDQidDNhiSwWEUQn3wIWE5G 4EIIxOJuw9LA5j++Y0ZojyoKDTPv/8Nqr/4uF0QTWV1LP49rxGG9nBLBNtzKe9YCFTGu KWV5fBjZbVinApKxbDQSfuCWkjCMaecnx9dm8G4Sw/4kfS+LrLaYKXKs+VrCDoIl8jsW 6FMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052772; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8V+IWdBYw8MK5GfswCmGJSJSTT+akxzrw5rFlMbMC5w=; b=cN9ELWhj/xjOAmIWdmpGt6ubq8aMidpqu4ojr2OuFRYrM6d3VYGfBlzc7Ntrlm4sAY a46EXgoDHIAXOWYHRCvJQbKHvIxj9cs/+9HDCiy1TGrmouRK6TYg9AFwlW8yVUJ875ZF xbkW9V2u5gTQwiMpcvc7s0V0lP4ZoVbSgWlr2tcgbVJXCNK/xApYJYIZkcppz/MvvMLm w2NOUEkELfdZ+w5us15y8eQJIOeHvm5coN26xdpdKBVZGxtQEwEpNrcl4xV1/H3P+mFd oepJRfYkAqAgRY/rjPvshW7E92ZflOY22bh5WujlvMYpXK/DA6jCfHIp5zh3KWVNrn83 7ZOw== X-Gm-Message-State: AO0yUKUks4ow3WVbhg7Qez9oDl4eBdZv6aLQFq+iyvYOagtIuc4csFyi E7grpNxRp56a6QFDFu3wQZwdAg== X-Google-Smtp-Source: AK7set/RsZ3jc36gVmZD1kXoGolfdpW64pTkClw1HV091sT81ILy2HuyUrQUXlWMsLw6vkCmt8xlMA== X-Received: by 2002:a17:90a:1d1:b0:23d:3878:781e with SMTP id 17-20020a17090a01d100b0023d3878781emr2634120pjd.21.1679052772372; Fri, 17 Mar 2023 04:32:52 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:32:52 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 02/11] misc: pci_endpoint_test: Remove an unused variable Date: Fri, 17 Mar 2023 20:32:29 +0900 Message-Id: <20230317113238.142970-3-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The use_dma variables are used only once. Remove those. Signed-off-by: Shunsuke Mie --- drivers/misc/pci_endpoint_test.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 22e0cc0b75d3..55733dee95ad 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -363,7 +363,6 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, void *src_addr; void *dst_addr; u32 flags = 0; - bool use_dma; size_t size; dma_addr_t src_phys_addr; dma_addr_t dst_phys_addr; @@ -392,8 +391,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, size = param.size; - use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); - if (use_dma) + if (param.flags & PCITEST_FLAGS_USE_DMA) flags |= FLAG_USE_DMA; orig_src_addr = kzalloc(size + alignment, GFP_KERNEL); @@ -496,7 +494,6 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, struct pci_endpoint_test_xfer_param param; bool ret = false; u32 flags = 0; - bool use_dma; u32 reg; void *addr; dma_addr_t phys_addr; @@ -523,8 +520,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size = param.size; - use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); - if (use_dma) + if (param.flags & PCITEST_FLAGS_USE_DMA) flags |= FLAG_USE_DMA; orig_addr = kzalloc(size + alignment, GFP_KERNEL); @@ -592,7 +588,6 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, struct pci_endpoint_test_xfer_param param; bool ret = false; u32 flags = 0; - bool use_dma; size_t size; void *addr; dma_addr_t phys_addr; @@ -618,8 +613,7 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size = param.size; - use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); - if (use_dma) + if (param.flags & PCITEST_FLAGS_USE_DMA) flags |= FLAG_USE_DMA; orig_addr = kzalloc(size + alignment, GFP_KERNEL); From patchwork Fri Mar 17 11:32:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178928 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 E4233C6FD1D for ; Fri, 17 Mar 2023 11:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbjCQLdK (ORCPT ); Fri, 17 Mar 2023 07:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbjCQLdG (ORCPT ); Fri, 17 Mar 2023 07:33:06 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A9CD6EB82 for ; Fri, 17 Mar 2023 04:32:56 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id v21so4965528ple.9 for ; Fri, 17 Mar 2023 04:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5sI1q8FeCzoYjS80FmoBFGlXkDMRicrucbVZQV9c508=; b=wtuEZ6mlE8yg3VIJrKgHJ8dxGzj9nc/+1LNPpzE/t7m7nzMWHIbgWeb86J9hRAi91l 72XaVrh9ZwfvmMuoJ8toT+QOBHeTUOVbQY7e59rUy4gqx4UhUHBvwkAel4ljh4iPwMcI lnXvt8iO39tYxEYzMfMEGf8tCqLJ2RMovRACyBYEug7De+x3HnSlu9cDdu952iVB1Rmk Dw9SW3Vmdp1BveJfi2a2FplQyfknon1qcXKBKcyybzVKeumW/kLaxyhj5MiZwHkG29an hbAHQItpw41sOAjdNuHGr6CeItUEFHQxF/o0248m1qTbpxOT6k5YoZhDVo9/A8L9rxZY vJ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5sI1q8FeCzoYjS80FmoBFGlXkDMRicrucbVZQV9c508=; b=XtEOotZF/24AUA3glYDtCb2ff8m19rVdxcMtyAOYN0xlXzrnggPmf68afcb0EjIRfg LoTMmord8cWJrq4VclIHONfa2gdaRbGDGqLCc2v58dZqzrRpD8i1PPlamLUElrnHhIpc kG3QwwgF2sjdrmJ+Bn0SHnGmBUzMCRmT3uClDupNraqXUscxcN2W7uO9QOJyQgfVeEQn Aix3f+OI7ARMm0uvd6oXLz8NZIbeHmNji9Ju2fjoRYz0ZDhUEQni6eeSSmIAYSAISnML hI8HWgOpIkdBx4WVLdBJ4IJnHlzwbKsMcfxZmHQ3a7dOylDrm72qBrI+ZZ2tBkCmIDLQ ViTw== X-Gm-Message-State: AO0yUKW9REDc1EdRx3rI5SYZQkGDREXTjMmt1l1MRT0NWvNpkaGMIvBt 5EEwWfHO30iJRtl7Z1/HNbc2zQ== X-Google-Smtp-Source: AK7set8HF6l0jo84zLOB7MX/fRtN4brKhFNLhH2+J96cVLUVYh0wHNh/ZygV2azN5x17QV/AqFWT6w== X-Received: by 2002:a17:90b:3b4d:b0:233:ee50:d28b with SMTP id ot13-20020a17090b3b4d00b00233ee50d28bmr8170087pjb.16.1679052776174; Fri, 17 Mar 2023 04:32:56 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:32:55 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 03/11] pci: endpoint: function/pci-epf-test: Unify a range of time measurement Date: Fri, 17 Mar 2023 20:32:30 +0900 Message-Id: <20230317113238.142970-4-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org This test code measures a time of data transfer. Some measurements include print, preparation and error checking. Change to measure during data tansfer. Signed-off-by: Shunsuke Mie --- drivers/pci/endpoint/functions/pci-epf-test.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 172e5ac0bd96..6955a3d2eb7e 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -356,7 +356,6 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) goto err_dst_addr; } - ktime_get_ts64(&start); use_dma = !!(reg->flags & FLAG_USE_DMA); if (use_dma) { if (!epf_test->dma_supported) { @@ -371,9 +370,11 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) goto err_map_addr; } + ktime_get_ts64(&start); ret = pci_epf_test_data_transfer(epf_test, dst_phys_addr, src_phys_addr, reg->size, 0, DMA_MEM_TO_MEM); + ktime_get_ts64(&end); if (ret) dev_err(dev, "Data transfer failed\n"); } else { @@ -385,11 +386,13 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) goto err_map_addr; } + ktime_get_ts64(&start); memcpy_fromio(buf, src_addr, reg->size); memcpy_toio(dst_addr, buf, reg->size); + ktime_get_ts64(&end); kfree(buf); } - ktime_get_ts64(&end); + pci_epf_test_print_rate("COPY", reg->size, &start, &end, use_dma); err_map_addr: @@ -467,9 +470,9 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) ret = pci_epf_test_data_transfer(epf_test, dst_phys_addr, phys_addr, reg->size, reg->src_addr, DMA_DEV_TO_MEM); + ktime_get_ts64(&end); if (ret) dev_err(dev, "Data transfer failed\n"); - ktime_get_ts64(&end); dma_unmap_single(dma_dev, dst_phys_addr, reg->size, DMA_FROM_DEVICE); @@ -556,14 +559,13 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) } ktime_get_ts64(&start); - ret = pci_epf_test_data_transfer(epf_test, phys_addr, src_phys_addr, reg->size, reg->dst_addr, DMA_MEM_TO_DEV); + ktime_get_ts64(&end); if (ret) dev_err(dev, "Data transfer failed\n"); - ktime_get_ts64(&end); dma_unmap_single(dma_dev, src_phys_addr, reg->size, DMA_TO_DEVICE); From patchwork Fri Mar 17 11:32:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178934 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 604B2C74A5B for ; Fri, 17 Mar 2023 11:33:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbjCQLdR (ORCPT ); Fri, 17 Mar 2023 07:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjCQLdI (ORCPT ); Fri, 17 Mar 2023 07:33:08 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 882C8763D2 for ; Fri, 17 Mar 2023 04:33:00 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id p3-20020a17090a74c300b0023f69bc7a68so388458pjl.4 for ; Fri, 17 Mar 2023 04:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=02xUqfEugvmsV40WG30Qa2tXUYlhWNLWy8/nr55CGig=; b=4P4Ag5T9O6UF2JNgzQOd/XqYteXdWN+gFSUKQfREV6+na/dzjZVvbtd7t75wSjkLRz sfU1y6//aC0sRcbKwiErqhP47Kmig9CO7GRffsItnE6N8g2uSH85vX0htlJYkWwRhqiV 750xt0J/CkT6CpRIR9AsM9BxJ5aemjO/m6GuwYGupnSG509fpD4R7n9wdJJ/YElw20I6 c66wi5hzNT0t0/Jb/ATPCTm9XBpQwqOlli87yEKbNyOcJeoDECZg0D3GY2CS8SJciqIQ eb4JnVfDE/pvvt8VRz6KvGDn5NYE3kjgCubYAMslqcvqzt2LM8gM8MUZNe9I2F0ohubi 08DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=02xUqfEugvmsV40WG30Qa2tXUYlhWNLWy8/nr55CGig=; b=d2iqI+YX10pl07DqMvo1iBSF7FFr7zGOpD3O/h1Mv2JiaGIwIH0FwkaiLSAWX+jH/h x3bLtDm8FHb6Ql0qCTlMU6+3wvwKGB0im3eCTmAbO7IH/bdV7Ez6V5VuWBtia6ikiiky MeKYS+fGRZuG4oBY0uxv4w3XAdqial9Kqt+h+dNdksKKB1ONBeIkt6thI2D007d133AP Keo1j5iWS2PKEzdfrE32a56PJbgGnxvIMvy+Mqs3tqVYlt+NWZtAyMtXwYM144aqwV6G PiNjccIBhJc1EH3HubPtyMcq3LFXprSbqV+Zm7TpTBRR0bD8LE7B+WZQIeoYIjzL1BfE S34w== X-Gm-Message-State: AO0yUKVuFbpaiW3jPkW2Tqs4QIOG8w6PDYI12096axHY0+78XEIRUhsQ bR6C/8fk9wN31baybRoKJnWcrQ== X-Google-Smtp-Source: AK7set8YHzFZhlF4nGvlioh0immV7c7RJw5smiE65VQhF7yAnNjifH85xfnz7kikkGdWtEdESDV8iQ== X-Received: by 2002:a17:903:110d:b0:1a1:93d0:e807 with SMTP id n13-20020a170903110d00b001a193d0e807mr7608803plh.36.1679052779764; Fri, 17 Mar 2023 04:32:59 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:32:59 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 04/11] PCI: endpoint: functions/pci-epf-test: Move common difinitions to header file Date: Fri, 17 Mar 2023 20:32:31 +0900 Message-Id: <20230317113238.142970-5-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The pci-epf-test and pci_endpoint_test drivers communicate by registers on PCIe BAR. The register details are duplicated in their code respectively. Move a common part to an introduced header file from pci-epf-test. Signed-off-by: Shunsuke Mie --- drivers/pci/endpoint/functions/pci-epf-test.c | 37 +--------- include/linux/pci-epf-test.h | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+), 36 deletions(-) create mode 100644 include/linux/pci-epf-test.h diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 6955a3d2eb7e..99d8a05b8507 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -17,31 +17,9 @@ #include #include +#include #include -#define IRQ_TYPE_LEGACY 0 -#define IRQ_TYPE_MSI 1 -#define IRQ_TYPE_MSIX 2 - -#define COMMAND_RAISE_LEGACY_IRQ BIT(0) -#define COMMAND_RAISE_MSI_IRQ BIT(1) -#define COMMAND_RAISE_MSIX_IRQ BIT(2) -#define COMMAND_READ BIT(3) -#define COMMAND_WRITE BIT(4) -#define COMMAND_COPY BIT(5) - -#define STATUS_READ_SUCCESS BIT(0) -#define STATUS_READ_FAIL BIT(1) -#define STATUS_WRITE_SUCCESS BIT(2) -#define STATUS_WRITE_FAIL BIT(3) -#define STATUS_COPY_SUCCESS BIT(4) -#define STATUS_COPY_FAIL BIT(5) -#define STATUS_IRQ_RAISED BIT(6) -#define STATUS_SRC_ADDR_INVALID BIT(7) -#define STATUS_DST_ADDR_INVALID BIT(8) - -#define FLAG_USE_DMA BIT(0) - #define TIMER_RESOLUTION 1 static struct workqueue_struct *kpcitest_workqueue; @@ -60,19 +38,6 @@ struct pci_epf_test { const struct pci_epc_features *epc_features; }; -struct pci_epf_test_reg { - u32 magic; - u32 command; - u32 status; - u64 src_addr; - u64 dst_addr; - u32 size; - u32 checksum; - u32 irq_type; - u32 irq_number; - u32 flags; -} __packed; - static struct pci_epf_header test_header = { .vendorid = PCI_ANY_ID, .deviceid = PCI_ANY_ID, diff --git a/include/linux/pci-epf-test.h b/include/linux/pci-epf-test.h new file mode 100644 index 000000000000..636057c3377f --- /dev/null +++ b/include/linux/pci-epf-test.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PCI_EPF_TEST_H +#define __PCI_EPF_TEST_H + +struct pci_epf_test_reg { +#define PCI_ENDPOINT_TEST_MAGIC offsetof(struct pci_epf_test_reg, magic) + u32 magic; +#define PCI_ENDPOINT_TEST_COMMAND offsetof(struct pci_epf_test_reg, command) +#define COMMAND_RAISE_LEGACY_IRQ BIT(0) +#define COMMAND_RAISE_MSI_IRQ BIT(1) +#define COMMAND_RAISE_MSIX_IRQ BIT(2) +#define COMMAND_READ BIT(3) +#define COMMAND_WRITE BIT(4) +#define COMMAND_COPY BIT(5) + u32 command; +#define STATUS_READ_SUCCESS BIT(0) +#define STATUS_READ_FAIL BIT(1) +#define STATUS_WRITE_SUCCESS BIT(2) +#define STATUS_WRITE_FAIL BIT(3) +#define STATUS_COPY_SUCCESS BIT(4) +#define STATUS_COPY_FAIL BIT(5) +#define STATUS_IRQ_RAISED BIT(6) +#define STATUS_SRC_ADDR_INVALID BIT(7) +#define STATUS_DST_ADDR_INVALID BIT(8) +#define PCI_ENDPOINT_TEST_STATUS offsetof(struct pci_epf_test_reg, status) + u32 status; + union { +#define PCI_ENDPOINT_TEST_SRC_ADDR offsetof(struct pci_epf_test_reg, src_addr) + u64 src_addr; + struct { +#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR offsetof(struct pci_epf_test_reg, src_low) + u32 src_low; +#define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR offsetof(struct pci_epf_test_reg, src_high) + u32 src_high; + } __packed; + }; + union { +#define PCI_ENDPOINT_TEST_DST_ADDR offsetof(struct pci_epf_test_reg, dst_addr) + u64 dst_addr; + struct { +#define PCI_ENDPOINT_TEST_LOWER_DST_ADDR offsetof(struct pci_epf_test_reg, dst_low) + u32 dst_low; +#define PCI_ENDPOINT_TEST_UPPER_DST_ADDR offsetof(struct pci_epf_test_reg, dst_high) + u32 dst_high; + } __packed; + }; +#define PCI_ENDPOINT_TEST_SIZE offsetof(struct pci_epf_test_reg, size) + u32 size; +#define PCI_ENDPOINT_TEST_COUNT offsetof(struct pci_epf_test_reg, count) + u32 count; +#define PCI_ENDPOINT_TEST_CHECKSUM offsetof(struct pci_epf_test_reg, checksum) + u32 checksum; +#define PCI_ENDPOINT_TEST_IRQ_TYPE offsetof(struct pci_epf_test_reg, irq_type) +#define IRQ_TYPE_UNDEFINED -1 +#define IRQ_TYPE_LEGACY 0 +#define IRQ_TYPE_MSI 1 +#define IRQ_TYPE_MSIX 2 + u32 irq_type; +#define PCI_ENDPOINT_TEST_IRQ_NUMBER offsetof(struct pci_epf_test_reg, irq_number) + u32 irq_number; +#define PCI_ENDPOINT_TEST_FLAGS offsetof(struct pci_epf_test_reg, flags) +#define FLAG_USE_DMA BIT(0) + u32 flags; +} __packed; + +#endif /* __PCI_EPF_TEST_H */ From patchwork Fri Mar 17 11:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178935 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 76B25C74A5B for ; Fri, 17 Mar 2023 11:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230020AbjCQLd0 (ORCPT ); Fri, 17 Mar 2023 07:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbjCQLdX (ORCPT ); Fri, 17 Mar 2023 07:33:23 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85236A90B3 for ; Fri, 17 Mar 2023 04:33:04 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id u5so4973718plq.7 for ; Fri, 17 Mar 2023 04:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4iadPnAZmhsjWHxwMakcLwCHZfPYJGTmA/4ZcjoDKLE=; b=cNxNwaDBvRQmJinsBZUY5SpY/BRLnT3sn/ZuYenOqjV8bNs9gzBJiP8XDNNipnex/d SSAxhnm9/x33lz7Ci6LsaOyUrcsVsqeVAlSvpj93Dhv0BrS3/tQajdxU+ThT0QLf1QhT 01l1nQFqaS3kyaRht0ChqovhYp9DmbW6DWyC0zNMk6AwnA3fuqmrP/EwTnN4fFJ2MFyj NW8slonzbP2p9sfvse/Kgj5gTlxWFONglv5lUsMAzS7ort8BTaACKPwbX9u0aErVTvy5 Kotlud6lIbgckHk7othS57WotvkRtLyG0heCxiFJZsOai8nFdAKFqRaDV8bV73dOo9o8 72EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4iadPnAZmhsjWHxwMakcLwCHZfPYJGTmA/4ZcjoDKLE=; b=S3xaeT6CAJXCfiJP+WjLMg0IBs2T2FB6VLyFKXOqweKMoME6jgIkqy3Q2EBbjVtkVg PHMqJN6mhjh+pdc7nq7gYBlXDFfCN6PNNZialBhSG6kQSRyxDGmDmNvlJWjh6CaPD75C ME4t/14cMJcgin7D4rh1SJZ8RS2PrHQfb+AaRJGyyBOJOhvnilmpuDq0GtdNCVfA5F33 +6EzY9Vgaay8UxEWQWjeyb8Wu+7v1CHCvfuZ+TlN3GkVtgVntBzlME71QZAY+oAGVWoy vhO9fKQYuaDw1PezySKm26EjHdbel/nJA0o5NTURB2Yf+S64dUxhd0kWJmyCbXoPgdgn 7qwA== X-Gm-Message-State: AO0yUKVWMEnD4VXUUfNCiC/H34b0qG7fVncMNOnEiF0VdF39yTHTVr2Y Sjb4aHqmOqTENtLWPC/zNRMwdg== X-Google-Smtp-Source: AK7set/qCnGBA0p9szajAWdSwnN3dFOPj1OdZtTeBXVH2xSXJIPYItlJH9avlXDIJ2Wli9AmPHquFQ== X-Received: by 2002:a17:90a:1a03:b0:237:2f3c:a1cd with SMTP id 3-20020a17090a1a0300b002372f3ca1cdmr8508780pjk.19.1679052783445; Fri, 17 Mar 2023 04:33:03 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:03 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 05/11] MAINTAINERS: Add a header file for pci-epf-test Date: Fri, 17 Mar 2023 20:32:32 +0900 Message-Id: <20230317113238.142970-6-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Common definitions between pci-epf-test and pci_endpoint_test drivers moves into the new header file. Signed-off-by: Shunsuke Mie --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 092f9500e0e7..440a7d0d4ac4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16131,6 +16131,7 @@ F: Documentation/misc-devices/pci-endpoint-test.rst F: drivers/misc/pci_endpoint_test.c F: drivers/pci/endpoint/ F: tools/pci/ +F: include/linux/pci-epf-test.h PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC M: Mahesh J Salgaonkar From patchwork Fri Mar 17 11:32:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178936 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 44115C74A5B for ; Fri, 17 Mar 2023 11:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjCQLdf (ORCPT ); Fri, 17 Mar 2023 07:33:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbjCQLdd (ORCPT ); Fri, 17 Mar 2023 07:33:33 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9252A56781 for ; Fri, 17 Mar 2023 04:33:07 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id h8so4960929plf.10 for ; Fri, 17 Mar 2023 04:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ob+dv03gMiw66cBwoU+hYD2Vt8Qv5SEsoU9zMOVBkuQ=; b=v0OVgL+DK0/1OLwNt1hvzurF9AgD0O2q65xQcB7iRde3gkzixBT/sZf5kAoAc6NM8n jNrxQKU2uVJ95IlWvsLGe9xQq/YJ3Pp0UGKMKFxzddpvDy9xSC15QsTeUNKJ5QbiQqa9 PSMNxlmk0HnYn6fAMswlbTqW/4ewcMn1GF8BwZN/bKF8nF0PO+5JkIc4JZb9tKsdgrd9 KdpZqxj4joy6mL0urr8Zyswjk0VO9NzvZmf41sEfhphLTVwt4AyyedBJjwzbR+TN0EmJ 3wBTUjByYqhE3ty4Mfe/Yk7LCEb/MYdZj3no50Ru+nhtOpUnQLJkkpVy+IsCD1I7t8sc l/3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ob+dv03gMiw66cBwoU+hYD2Vt8Qv5SEsoU9zMOVBkuQ=; b=hFH80zp+kgvxIHEGyuGmEes5k6Ip6Ou+o27ckYxhY8JfpjesZMUCo/tZV1Yf0H+Mgv wv2MiXLYxJvNiHdbEL0HzHl1kcKVswzN6Lsv5S4SyizHe9nSeYeDVVVZLFieCDaFMxe2 O2HG+FSmH4KavTXo/8Y9gTvjf9Me3L3cKsrayQNhsPM8ZGTtD6zPG24ixYk2zBkJO12t w/LP4WMwQ28zd4YILQigE1cFvy/IUz4kOKtH/qcX8E+/m5+a1mll2N3Gah9QmJVGf4b2 RnsZkCgj3VVtu2y5/fhtzXciUV+FdsSe/PXAK16zhNUO4LBDeygEAVvGk5l2K1UwLsLQ 3LXw== X-Gm-Message-State: AO0yUKUXMbqN1T58B7wooU6U2nQX+srV+r2DrmhpZFNKyTK4t0f7wEaC LmvdLxpAcBOj0A7YmVClsI+g6w== X-Google-Smtp-Source: AK7set/4cQfdbVb01q3i9EBygum5/NcOwZKrEbddz29AigoY+K4DZYp+9xpVs6i+I7fm8qg6riVLPw== X-Received: by 2002:a17:90b:3881:b0:23f:618a:6bed with SMTP id mu1-20020a17090b388100b0023f618a6bedmr1406906pjb.47.1679052787033; Fri, 17 Mar 2023 04:33:07 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:06 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 06/11] misc: pci_endpoint_test: Use a common header file between endpoint driver Date: Fri, 17 Mar 2023 20:32:33 +0900 Message-Id: <20230317113238.142970-7-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Duplicated definitions between pci-epf-test and pci_endpoint_test are already moved to a header file. Remove the common definitions and include the header file. In addition, the separate register address writes were combined into a single write. Signed-off-by: Shunsuke Mie --- drivers/misc/pci_endpoint_test.c | 42 +------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 55733dee95ad..d4a42e9ab86a 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -22,52 +22,12 @@ #include #include +#include #include #define DRV_MODULE_NAME "pci-endpoint-test" -#define IRQ_TYPE_UNDEFINED -1 -#define IRQ_TYPE_LEGACY 0 -#define IRQ_TYPE_MSI 1 -#define IRQ_TYPE_MSIX 2 - -#define PCI_ENDPOINT_TEST_MAGIC 0x0 - -#define PCI_ENDPOINT_TEST_COMMAND 0x4 -#define COMMAND_RAISE_LEGACY_IRQ BIT(0) -#define COMMAND_RAISE_MSI_IRQ BIT(1) -#define COMMAND_RAISE_MSIX_IRQ BIT(2) -#define COMMAND_READ BIT(3) -#define COMMAND_WRITE BIT(4) -#define COMMAND_COPY BIT(5) - -#define PCI_ENDPOINT_TEST_STATUS 0x8 -#define STATUS_READ_SUCCESS BIT(0) -#define STATUS_READ_FAIL BIT(1) -#define STATUS_WRITE_SUCCESS BIT(2) -#define STATUS_WRITE_FAIL BIT(3) -#define STATUS_COPY_SUCCESS BIT(4) -#define STATUS_COPY_FAIL BIT(5) -#define STATUS_IRQ_RAISED BIT(6) -#define STATUS_SRC_ADDR_INVALID BIT(7) -#define STATUS_DST_ADDR_INVALID BIT(8) - -#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c -#define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 - -#define PCI_ENDPOINT_TEST_LOWER_DST_ADDR 0x14 -#define PCI_ENDPOINT_TEST_UPPER_DST_ADDR 0x18 - -#define PCI_ENDPOINT_TEST_SIZE 0x1c -#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 - -#define PCI_ENDPOINT_TEST_IRQ_TYPE 0x24 -#define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 - -#define PCI_ENDPOINT_TEST_FLAGS 0x2c -#define FLAG_USE_DMA BIT(0) - #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f #define PCI_DEVICE_ID_TI_AM64 0xb010 From patchwork Fri Mar 17 11:32:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178937 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 B56C2C74A5B for ; Fri, 17 Mar 2023 11:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230078AbjCQLdt (ORCPT ); Fri, 17 Mar 2023 07:33:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbjCQLdt (ORCPT ); Fri, 17 Mar 2023 07:33:49 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F0E2AB887 for ; Fri, 17 Mar 2023 04:33:12 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id h8so4961099plf.10 for ; Fri, 17 Mar 2023 04:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XsdH0oLvA5PMhdbh6lug1hHlRUTM7D8rYh/xwgUFb5s=; b=mvu65/QfRfRZArhG2eSvUbIHdoFY4+XUZwAOfwXTe1cLvSbmcJMG1Kmiu6dWv5m+sV N7H2LviIzAS9sDn5AjrkYhybo0WDWwXYNfIzD/FaBPa3FtdWnklkMXUOLLlXJP47u7PV 2RSnZ24DTlFUNYaFwq8oq6qbiqtMOkwC9ILG7FGV+6u/iV21JyUVsT02+cTdERsgX/qX A6zj7Wkl1PpAup8r0VYcA85bsYauBVIq6sNO9QzpRJUISg6nSFLGCdjCcLZMxIthqssR Urfue+pE2rMnHktmFhN953n1+V0rUOZrCt4mUGc3MTzdrqPy1n8oeheLEkWk4fh9jURc tegA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XsdH0oLvA5PMhdbh6lug1hHlRUTM7D8rYh/xwgUFb5s=; b=Yr7thCkkhvOYLtZ5VnPMRX2RSDEmmzKw899nz+3xf8794t7WZER3shg1ozaDYufTbU r+nkx1CfQiai0FWGZedoLB4aHwuQxg49w/GgkjMOoROHtlNYIp1HmSxARbK8MrJYnBLd 2RXF7sv9h7km/LhmcJHfW1CRV0AkktwixkyIYFg3yQ+u6ZHFzCSRX8uWQN5FqJhVGFYu P0PKd3rN65ESDH7HeUc4h8gqzRVJ8qlJhJwJ8aQlW1Xh5LbvZOiSQ41QktEoJwwjDohi DLzbu9E3qiJM1JAFNv2R/4fLxfTBkJE3tg8NDNsd9i66ktliqCE9Mq6evkT6OcSZH1Vz 4wxA== X-Gm-Message-State: AO0yUKXjQF7z4kRxdLwoWgluog+5boLXw3/lleeGBdVLTsuWAxL4pRJf Mi4MImKa604AYUItGUBN7NlaIQ== X-Google-Smtp-Source: AK7set/uRUgDY2cX8naSHuM20nfNZ9dM/YY+xJQJECgmJbS3+imJdlIRZMryd8zO2HdBEbhtsUlhqA== X-Received: by 2002:a17:90b:1646:b0:23d:3aa5:5ff3 with SMTP id il6-20020a17090b164600b0023d3aa55ff3mr2791934pjb.14.1679052790713; Fri, 17 Mar 2023 04:33:10 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:10 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 07/11] PCI: endpoint: functions/pci-epf-test: Extend the test for continuous transfers Date: Fri, 17 Mar 2023 20:32:34 +0900 Message-Id: <20230317113238.142970-8-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The test could not test continuous DMAs because it was only synchronously issuing a single DMA and waiting for it to complete. Add a new parameter, `count` and extend the test for continuous transfers to improve the test coverage. Signed-off-by: Shunsuke Mie --- drivers/pci/endpoint/functions/pci-epf-test.c | 152 ++++++++++-------- 1 file changed, 84 insertions(+), 68 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 99d8a05b8507..7898dfd956db 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -63,6 +63,7 @@ static void pci_epf_test_dma_callback(void *param) * @dma_src: The source address of the data transfer. It can be a physical * address given by pci_epc_mem_alloc_addr or DMA mapping APIs. * @len: The size of the data transfer + * @count: The number of DMAs issuing in consecutive * @dma_remote: remote RC physical address * @dir: DMA transfer direction * @@ -74,7 +75,7 @@ static void pci_epf_test_dma_callback(void *param) */ static int pci_epf_test_data_transfer(struct pci_epf_test *epf_test, dma_addr_t dma_dst, dma_addr_t dma_src, - size_t len, dma_addr_t dma_remote, + size_t len, size_t count, dma_addr_t dma_remote, enum dma_transfer_direction dir) { struct dma_chan *chan = (dir == DMA_MEM_TO_DEV) ? @@ -87,47 +88,56 @@ static int pci_epf_test_data_transfer(struct pci_epf_test *epf_test, struct device *dev = &epf->dev; dma_cookie_t cookie; int ret; + int i; + size_t offset; if (IS_ERR_OR_NULL(chan)) { dev_err(dev, "Invalid DMA memcpy channel\n"); return -EINVAL; } - if (epf_test->dma_private) { - sconf.direction = dir; - if (dir == DMA_MEM_TO_DEV) - sconf.dst_addr = dma_remote; - else - sconf.src_addr = dma_remote; + for (i = 0, offset = 0; i < count; i++, offset += len) { + if (epf_test->dma_private) { + sconf.direction = dir; + if (dir == DMA_MEM_TO_DEV) + sconf.dst_addr = dma_remote + offset; + else + sconf.src_addr = dma_remote + offset; + + if (dmaengine_slave_config(chan, &sconf)) { + dev_err(dev, "DMA slave config fail\n"); + return -EIO; + } + tx = dmaengine_prep_slave_single( + chan, dma_local + offset, len, dir, flags); + } else { + tx = dmaengine_prep_dma_memcpy(chan, dma_dst + offset, + dma_src + offset, len, + flags); + } - if (dmaengine_slave_config(chan, &sconf)) { - dev_err(dev, "DMA slave config fail\n"); + if (!tx) { + dev_err(dev, "Failed to prepare DMA memcpy\n"); return -EIO; } - tx = dmaengine_prep_slave_single(chan, dma_local, len, dir, - flags); - } else { - tx = dmaengine_prep_dma_memcpy(chan, dma_dst, dma_src, len, - flags); - } - if (!tx) { - dev_err(dev, "Failed to prepare DMA memcpy\n"); - return -EIO; - } + if (i == count - 1) { + tx->callback = pci_epf_test_dma_callback; + tx->callback_param = epf_test; + reinit_completion(&epf_test->transfer_complete); + } - tx->callback = pci_epf_test_dma_callback; - tx->callback_param = epf_test; - cookie = tx->tx_submit(tx); - reinit_completion(&epf_test->transfer_complete); + cookie = tx->tx_submit(tx); - ret = dma_submit_error(cookie); - if (ret) { - dev_err(dev, "Failed to do DMA tx_submit %d\n", cookie); - return -EIO; + ret = dma_submit_error(cookie); + if (ret) { + dev_err(dev, "Failed to do DMA tx_submit %d\n", cookie); + return -EIO; + } + + dma_async_issue_pending(chan); } - dma_async_issue_pending(chan); ret = wait_for_completion_interruptible(&epf_test->transfer_complete); if (ret < 0) { dmaengine_terminate_sync(chan); @@ -244,7 +254,7 @@ static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test) return; } -static void pci_epf_test_print_rate(const char *ops, u64 size, +static void pci_epf_test_print_rate(const char *ops, u64 size, u32 count, struct timespec64 *start, struct timespec64 *end, bool dma) { @@ -255,7 +265,7 @@ static void pci_epf_test_print_rate(const char *ops, u64 size, /* convert both size (stored in 'rate') and time in terms of 'ns' */ ns = timespec64_to_ns(&ts); - rate = size * NSEC_PER_SEC; + rate = size * count * NSEC_PER_SEC; /* Divide both size (stored in 'rate') and ns by a common factor */ while (ns > UINT_MAX) { @@ -269,14 +279,14 @@ static void pci_epf_test_print_rate(const char *ops, u64 size, /* calculate the rate */ do_div(rate, (uint32_t)ns); - pr_info("\n%s => Size: %llu bytes\t DMA: %s\t Time: %llu.%09u seconds\t" - "Rate: %llu KB/s\n", ops, size, dma ? "YES" : "NO", + pr_info("\n%s => Size: %llu bytes\tcount %d\t DMA: %s\t Time: %llu.%09u seconds\t" + "Rate: %llu KB/s\n", ops, size, count, dma ? "YES" : "NO", (u64)ts.tv_sec, (u32)ts.tv_nsec, rate / 1024); } static int pci_epf_test_copy(struct pci_epf_test *epf_test) { - int ret; + int ret, i; bool use_dma; void __iomem *src_addr; void __iomem *dst_addr; @@ -288,8 +298,9 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) struct pci_epc *epc = epf->epc; enum pci_barno test_reg_bar = epf_test->test_reg_bar; struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; + size_t offset; - src_addr = pci_epc_mem_alloc_addr(epc, &src_phys_addr, reg->size); + src_addr = pci_epc_mem_alloc_addr(epc, &src_phys_addr, reg->size * reg->count); if (!src_addr) { dev_err(dev, "Failed to allocate source address\n"); reg->status = STATUS_SRC_ADDR_INVALID; @@ -298,14 +309,14 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) } ret = pci_epc_map_addr(epc, epf->func_no, epf->vfunc_no, src_phys_addr, - reg->src_addr, reg->size); + reg->src_addr, reg->size * reg->count); if (ret) { dev_err(dev, "Failed to map source address\n"); reg->status = STATUS_SRC_ADDR_INVALID; goto err_src_addr; } - dst_addr = pci_epc_mem_alloc_addr(epc, &dst_phys_addr, reg->size); + dst_addr = pci_epc_mem_alloc_addr(epc, &dst_phys_addr, reg->size * reg->count); if (!dst_addr) { dev_err(dev, "Failed to allocate destination address\n"); reg->status = STATUS_DST_ADDR_INVALID; @@ -314,7 +325,7 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) } ret = pci_epc_map_addr(epc, epf->func_no, epf->vfunc_no, dst_phys_addr, - reg->dst_addr, reg->size); + reg->dst_addr, reg->size * reg->count); if (ret) { dev_err(dev, "Failed to map destination address\n"); reg->status = STATUS_DST_ADDR_INVALID; @@ -337,7 +348,7 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) ktime_get_ts64(&start); ret = pci_epf_test_data_transfer(epf_test, dst_phys_addr, - src_phys_addr, reg->size, 0, + src_phys_addr, reg->size, reg->count, 0, DMA_MEM_TO_MEM); ktime_get_ts64(&end); if (ret) @@ -345,32 +356,33 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) } else { void *buf; - buf = kzalloc(reg->size, GFP_KERNEL); + buf = kzalloc(reg->size * reg->count, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto err_map_addr; } ktime_get_ts64(&start); - memcpy_fromio(buf, src_addr, reg->size); - memcpy_toio(dst_addr, buf, reg->size); + for (i = 0, offset = 0; i < reg->count; i++, offset += reg->size) { + memcpy_fromio(buf + offset, src_addr + offset, reg->size); + memcpy_toio(dst_addr + offset, buf + offset, reg->size); + } ktime_get_ts64(&end); kfree(buf); } - - pci_epf_test_print_rate("COPY", reg->size, &start, &end, use_dma); + pci_epf_test_print_rate("COPY", reg->size, reg->count, &start, &end, use_dma); err_map_addr: pci_epc_unmap_addr(epc, epf->func_no, epf->vfunc_no, dst_phys_addr); err_dst_addr: - pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size); + pci_epc_mem_free_addr(epc, dst_phys_addr, dst_addr, reg->size * reg->count); err_src_map_addr: pci_epc_unmap_addr(epc, epf->func_no, epf->vfunc_no, src_phys_addr); err_src_addr: - pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size); + pci_epc_mem_free_addr(epc, src_phys_addr, src_addr, reg->size * reg->count); err: return ret; @@ -378,7 +390,7 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test) static int pci_epf_test_read(struct pci_epf_test *epf_test) { - int ret; + int ret, i; void __iomem *src_addr; void *buf; u32 crc32; @@ -392,8 +404,9 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) struct device *dma_dev = epf->epc->dev.parent; enum pci_barno test_reg_bar = epf_test->test_reg_bar; struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; + size_t offset; - src_addr = pci_epc_mem_alloc_addr(epc, &phys_addr, reg->size); + src_addr = pci_epc_mem_alloc_addr(epc, &phys_addr, reg->size * reg->count); if (!src_addr) { dev_err(dev, "Failed to allocate address\n"); reg->status = STATUS_SRC_ADDR_INVALID; @@ -402,14 +415,14 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) } ret = pci_epc_map_addr(epc, epf->func_no, epf->vfunc_no, phys_addr, - reg->src_addr, reg->size); + reg->src_addr, reg->size * reg->count); if (ret) { dev_err(dev, "Failed to map address\n"); reg->status = STATUS_SRC_ADDR_INVALID; goto err_addr; } - buf = kzalloc(reg->size, GFP_KERNEL); + buf = kzalloc(reg->size * reg->count, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto err_map_addr; @@ -423,7 +436,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) goto err_dma_map; } - dst_phys_addr = dma_map_single(dma_dev, buf, reg->size, + dst_phys_addr = dma_map_single(dma_dev, buf, reg->size * reg->count, DMA_FROM_DEVICE); if (dma_mapping_error(dma_dev, dst_phys_addr)) { dev_err(dev, "Failed to map destination buffer addr\n"); @@ -433,23 +446,24 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) ktime_get_ts64(&start); ret = pci_epf_test_data_transfer(epf_test, dst_phys_addr, - phys_addr, reg->size, + phys_addr, reg->size, reg->count, reg->src_addr, DMA_DEV_TO_MEM); ktime_get_ts64(&end); if (ret) dev_err(dev, "Data transfer failed\n"); - dma_unmap_single(dma_dev, dst_phys_addr, reg->size, + dma_unmap_single(dma_dev, dst_phys_addr, reg->size * reg->count, DMA_FROM_DEVICE); } else { ktime_get_ts64(&start); - memcpy_fromio(buf, src_addr, reg->size); + for (i = 0, offset = 0; i < reg->count; i++, offset += reg->size) + memcpy_fromio(buf + offset, src_addr + offset, reg->size); ktime_get_ts64(&end); } - pci_epf_test_print_rate("READ", reg->size, &start, &end, use_dma); + pci_epf_test_print_rate("READ", reg->size, reg->count, &start, &end, use_dma); - crc32 = crc32_le(~0, buf, reg->size); + crc32 = crc32_le(~0, buf, reg->size * reg->count); if (crc32 != reg->checksum) ret = -EIO; @@ -460,7 +474,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) pci_epc_unmap_addr(epc, epf->func_no, epf->vfunc_no, phys_addr); err_addr: - pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size); + pci_epc_mem_free_addr(epc, phys_addr, src_addr, reg->size * reg->count); err: return ret; @@ -468,7 +482,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) static int pci_epf_test_write(struct pci_epf_test *epf_test) { - int ret; + int ret, i; void __iomem *dst_addr; void *buf; bool use_dma; @@ -481,8 +495,9 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) struct device *dma_dev = epf->epc->dev.parent; enum pci_barno test_reg_bar = epf_test->test_reg_bar; struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; + size_t offset; - dst_addr = pci_epc_mem_alloc_addr(epc, &phys_addr, reg->size); + dst_addr = pci_epc_mem_alloc_addr(epc, &phys_addr, reg->size * reg->count); if (!dst_addr) { dev_err(dev, "Failed to allocate address\n"); reg->status = STATUS_DST_ADDR_INVALID; @@ -491,21 +506,21 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) } ret = pci_epc_map_addr(epc, epf->func_no, epf->vfunc_no, phys_addr, - reg->dst_addr, reg->size); + reg->dst_addr, reg->size * reg->count); if (ret) { dev_err(dev, "Failed to map address\n"); reg->status = STATUS_DST_ADDR_INVALID; goto err_addr; } - buf = kzalloc(reg->size, GFP_KERNEL); + buf = kzalloc(reg->size * reg->count, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto err_map_addr; } - get_random_bytes(buf, reg->size); - reg->checksum = crc32_le(~0, buf, reg->size); + get_random_bytes(buf, reg->size * reg->count); + reg->checksum = crc32_le(~0, buf, reg->size * reg->count); use_dma = !!(reg->flags & FLAG_USE_DMA); if (use_dma) { @@ -515,7 +530,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) goto err_dma_map; } - src_phys_addr = dma_map_single(dma_dev, buf, reg->size, + src_phys_addr = dma_map_single(dma_dev, buf, reg->size * reg->count, DMA_TO_DEVICE); if (dma_mapping_error(dma_dev, src_phys_addr)) { dev_err(dev, "Failed to map source buffer addr\n"); @@ -525,22 +540,23 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) ktime_get_ts64(&start); ret = pci_epf_test_data_transfer(epf_test, phys_addr, - src_phys_addr, reg->size, + src_phys_addr, reg->size, reg->count, reg->dst_addr, DMA_MEM_TO_DEV); ktime_get_ts64(&end); if (ret) dev_err(dev, "Data transfer failed\n"); - dma_unmap_single(dma_dev, src_phys_addr, reg->size, + dma_unmap_single(dma_dev, src_phys_addr, reg->size * reg->count, DMA_TO_DEVICE); } else { ktime_get_ts64(&start); - memcpy_toio(dst_addr, buf, reg->size); + for (i = 0, offset = 0; i < reg->count; i++, offset += reg->size) + memcpy_toio(dst_addr + offset, buf + offset, reg->size); ktime_get_ts64(&end); } - pci_epf_test_print_rate("WRITE", reg->size, &start, &end, use_dma); + pci_epf_test_print_rate("WRITE", reg->size, reg->count, &start, &end, use_dma); /* * wait 1ms inorder for the write to complete. Without this delay L3 @@ -555,7 +571,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) pci_epc_unmap_addr(epc, epf->func_no, epf->vfunc_no, phys_addr); err_addr: - pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size); + pci_epc_mem_free_addr(epc, phys_addr, dst_addr, reg->size * reg->count); err: return ret; From patchwork Fri Mar 17 11:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178938 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 A4AE8C74A5B for ; Fri, 17 Mar 2023 11:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjCQLdy (ORCPT ); Fri, 17 Mar 2023 07:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbjCQLdw (ORCPT ); Fri, 17 Mar 2023 07:33:52 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9329ABAD4 for ; Fri, 17 Mar 2023 04:33:14 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id j13so4775743pjd.1 for ; Fri, 17 Mar 2023 04:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FeG3wRBDmKNCCUZ5fz5gWcA/vZS940xFTGQw0n7HN+E=; b=O6SXGDuUKlQ+9oQOkCmvU04ck+RyNmL8hdU9s6Nvyza/sjnC2hq+lrJ9WuLhWElkb3 H6nH2JAjDt+A244Vi+2jSnJwNmdXNoe06nDr6Buxuui+5GUDvNxTeHtW0kF8rupLT6yv k/g6AHHcoxIXZVxEQ+JC3ebI6vI33WynceSPnNbAm0WhNp+rKo2H56Z+4xP6BGJ50yRh cLDex5tzITakt+e7nJwbUniSCYNydjTm2Au706qpmhGfgNs+oCaIGTYYenpQ2M4KxzLY XqVZPXqsav7oT6hhUsohmbzC/l4HWG51jCW4qvFFpFJ6Etv0POdkma8qEasDCWdv4o4i d5tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FeG3wRBDmKNCCUZ5fz5gWcA/vZS940xFTGQw0n7HN+E=; b=P2Zpaw+hlRM7OSwuzfzfIKoxwboeH+hvPYO/W/i0XcGVCbrOli7PBBGInNBIzSDeVP jcHtaIv8zsz3TNFYBxH+NZL+SC2Q5bsodQAJBXyaMW4PY/HQxvRys95Et4FXdHXbYgau thA13R8K34WaWRuX9wGan5oVmCCxGlcPhvSHuQT7UAAyd5VpcTPBJR45dKu8mnHflDCI OHoCqt0QZMVxUExwoBY8htumjBjTaNqkQ/jeIvaHrWN9kEQh4OavuMQqZ7j0S5L8ygfQ 2QVhYkLdmsbn20fEA4950H3KPlo4XnoHd2+AUeJin5mI2NZa3hZkJPWGWV4+G9GsfMaN awGg== X-Gm-Message-State: AO0yUKVZ62vpMZfhCPrIuL1rHJ8oQ/P0Z6IVbvlVlBJO7nQtCA7s72XS CGS0MLbXNZBb50kzBJvRGZ2+jw== X-Google-Smtp-Source: AK7set+NQnSKYe8rjJOnq8VGzJNvTIqjYGfSG9K3yeXxMJf6U4NYDvg9R2U3W1W0s4+0B9RWCEeMgA== X-Received: by 2002:a17:90a:e7cc:b0:237:c52f:a54d with SMTP id kb12-20020a17090ae7cc00b00237c52fa54dmr2618477pjb.21.1679052794296; Fri, 17 Mar 2023 04:33:14 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:14 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , 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 Message-Id: <20230317113238.142970-9-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org 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 --- 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; }; From patchwork Fri Mar 17 11:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178939 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 3DE25C7618B for ; Fri, 17 Mar 2023 11:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbjCQLeA (ORCPT ); Fri, 17 Mar 2023 07:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjCQLd7 (ORCPT ); Fri, 17 Mar 2023 07:33:59 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 691B4A8C62 for ; Fri, 17 Mar 2023 04:33:18 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id i5so4990332pla.2 for ; Fri, 17 Mar 2023 04:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=znKfKtHV6TgFWLrDIG0H6CwhrMa6Sg0ibY+beHEykvU=; b=ueqNZvZn+HPM/j87SWRqQzkqDAM75u9n1eh0Ej8ZqQ5w4ZsnWheJsDzwp60Jtezhyo OC4CifyjKZYzPQM7wNV4Lez3j5u55SR2ZzclpJBDyp0CYKTJ2SwQXtWvlWj2cvmdY97a +STY2TuVveQdjgZTYR1ozzT1wSJccym7hxbInqTZlbtbmTDETsP6cnPm7y4Z8BH/WsTo n85euSBP3Bf1kLhUjXNKrY9E3kX0IqwZIP1yui7quTzz4weWt/s2YF0Y86AITyuz8EuJ at6v903i3AEidzNB3kh0mHbQHIBiDUF6bp2xZE/poJuVJBHDeeaZukQHOhzD6JZHJmDH t7uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=znKfKtHV6TgFWLrDIG0H6CwhrMa6Sg0ibY+beHEykvU=; b=iqNFU4+JEIUc1ZnWBDvoJ8kJgz109XEsAgLG+91kR7Xdc6o4vTPJBgjpBTzdI3FHzs zZpu1polAOAVPr7dIYrKddJzNTT4eKdd5CeOI87+30Asc8T2l72ZmlikgKzk5g4Jazi/ JWRyIlFbmojucS+xOif8K2UPXq4kSJA7Vx2+HC1H/zFK+8zh33hEmJcCYjbFG9w2gX31 AU3T15iOSHnFL8LVCEKI1eJm8bXaBVr+jhhAwrn8u6sQ9RJjKGpLr4MOE/fnbphiSxXm noheXLYb5SpwxOGWLW2ZzedF56r2sxclBB5qCSmzaelif+S6fR8oDN46qo1t0SQiOy7j uRBA== X-Gm-Message-State: AO0yUKWFkf00cn8lTPNRHp33CuQcp3ZFL+PCHADJyvHMB6/zKUmQkxhV hheVNtCbPXzXUQBeeX0Jy7GmJ4i2UUyxUUNmWpc= X-Google-Smtp-Source: AK7set/LgrS1REaYSHbX7wy9zHzuHqlQGfTkMV7xpn0Bgj4jZ+J0GnfpGtRwL4MisMzUmi3zDFRDKg== X-Received: by 2002:a17:90b:17cb:b0:23d:3057:12a3 with SMTP id me11-20020a17090b17cb00b0023d305712a3mr7729422pjb.27.1679052797846; Fri, 17 Mar 2023 04:33:17 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:17 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 09/11] tools: PCI: Add 'C' option to support continuous transfer Date: Fri, 17 Mar 2023 20:32:36 +0900 Message-Id: <20230317113238.142970-10-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Add a new command line option 'C' to specify the number of transfers to perform continuously. This option helps to detect problem of DMAC in DMA transfers. By default, the number is set to 1. Signed-off-by: Shunsuke Mie --- tools/pci/pcitest.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 441b54234635..a66b28e1e65e 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -35,6 +35,7 @@ struct pci_test { bool write; bool copy; unsigned long size; + unsigned long count; bool use_dma; }; @@ -115,6 +116,7 @@ static int run_test(struct pci_test *test) if (test->write) { param.size = test->size; + param.count = test->count; if (test->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; ret = ioctl(fd, PCITEST_WRITE, ¶m); @@ -127,6 +129,7 @@ static int run_test(struct pci_test *test) if (test->read) { param.size = test->size; + param.count = test->count; if (test->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; ret = ioctl(fd, PCITEST_READ, ¶m); @@ -139,6 +142,7 @@ static int run_test(struct pci_test *test) if (test->copy) { param.size = test->size; + param.count = test->count; if (test->use_dma) param.flags = PCITEST_FLAGS_USE_DMA; ret = ioctl(fd, PCITEST_COPY, ¶m); @@ -171,10 +175,13 @@ int main(int argc, char **argv) /* set default size as 100KB */ test->size = 0x19000; + /* set default transfer count */ + test->count = 1; + /* set default endpoint device */ test->device = "/dev/pci-endpoint-test.0"; - while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF) + while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:C:")) != EOF) switch (c) { case 'D': test->device = optarg; @@ -221,6 +228,9 @@ int main(int argc, char **argv) case 's': test->size = strtoul(optarg, NULL, 0); continue; + case 'C': + test->count = strtoul(optarg, NULL, 0); + continue; case 'd': test->use_dma = true; continue; @@ -243,6 +253,7 @@ int main(int argc, char **argv) "\t-w Write buffer test\n" "\t-c Copy buffer test\n" "\t-s Size of buffer {default: 100KB}\n" + "\t-C Number of The continuous data transfers {default: 1}\n" "\t-h Print this help message\n", argv[0]); return -EINVAL; From patchwork Fri Mar 17 11:32:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178940 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 453E4C6FD1D for ; Fri, 17 Mar 2023 11:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbjCQLeJ (ORCPT ); Fri, 17 Mar 2023 07:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbjCQLeG (ORCPT ); Fri, 17 Mar 2023 07:34:06 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D4053281 for ; Fri, 17 Mar 2023 04:33:23 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id le6so4956236plb.12 for ; Fri, 17 Mar 2023 04:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dEWvzeZcqK871MfRmlZTSC0+Rvvt2fdWWI9+tB+ygs8=; b=A9d6Me/U+38g8tYFkHJboHIB24mipqPLRwBsFdf8QUZKGyqMVI3+7nJy7pjnKEW1cz 7tyAc9Ar6ITDWVM3La5oW1UclxYpTBwGApriRVy/0QPOn9vPXrbBuLzv0CjvsznaqOPB zIz9Z2KSkNrX7wt/LUthw8aR8Xpib389ogzxBC99Jq41y5+GzBO0aw6O52qtv18dh4wO nKg6MOih323wL5HenFkvYjNokMPR/aZPQwe2+zKFM/XHWhbwKtkj7XM7JYMIRSzlxV14 5EIKlT43jK7fnSN/cOFw2Hhtjpr3T2BdAOFqX7R/F+qzwjGTOHmcMWLXs/kp9ctvbqJj BDnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dEWvzeZcqK871MfRmlZTSC0+Rvvt2fdWWI9+tB+ygs8=; b=q4UF635Mxam6/9aHgHuJVCm+TUTwRY69/s/IRnG2h7MBQ20aFXRtG5YixI8crigX8J /6WiBt+w42CV/8Mij0w2m56Q857z2L8HawsX54JG/sw4VY8BofBLKvfiS1YmeedID8pM iOX/QOW0DobAvdjbq1xJiiMSi7M+H8maGGLa7Le4SjC6BJ7/QjLZS1wJ+a8Eyi9ouZRz UqVweotbp/vuf0p7mQ24iXIBJkQxfeJVBGz8LfiK4uByoU0TRPtv4IEBxc3TnhGQc+lt kD7W7o2zxH+mgyYK8OWGSr4sah48HpI+pbFhBJ1sAi8BQSx4dfrc+1Aej0tAbKmCume3 9rdw== X-Gm-Message-State: AO0yUKV90tkfi58X+hFcaEzwBIFEjW/yZ4MNyzZDz7NX3W7OK5iq6QyO 5p5Z4LjBl2fwPdw5LLcd/P2yBQ== X-Google-Smtp-Source: AK7set+TPpYwApi7RqjbM4INqbH8WoK4AaTlrq4ktuIO2IWD/jWG8Ua248P+wQDOKsbMN7p5EOdeRw== X-Received: by 2002:a17:90b:17cb:b0:236:73d5:82cf with SMTP id me11-20020a17090b17cb00b0023673d582cfmr7715034pjb.9.1679052801454; Fri, 17 Mar 2023 04:33:21 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:21 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 10/11] dmaengine: dw-edma: Fix to change for continuous transfer Date: Fri, 17 Mar 2023 20:32:37 +0900 Message-Id: <20230317113238.142970-11-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The dw-edma driver stops after processing a DMA request even if a request remains in the issued queue, which is not the expected behavior. The DMA engine API requires continuous processing. Add a trigger to start after one processing finished if there are requests remain. Fixes: e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver") Signed-off-by: Shunsuke Mie --- drivers/dma/dw-edma/dw-edma-core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index 1906a836f0aa..c527af00ff4e 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -181,7 +181,7 @@ static void vchan_free_desc(struct virt_dma_desc *vdesc) dw_edma_free_desc(vd2dw_edma_desc(vdesc)); } -static void dw_edma_start_transfer(struct dw_edma_chan *chan) +static int dw_edma_start_transfer(struct dw_edma_chan *chan) { struct dw_edma_chunk *child; struct dw_edma_desc *desc; @@ -189,16 +189,16 @@ static void dw_edma_start_transfer(struct dw_edma_chan *chan) vd = vchan_next_desc(&chan->vc); if (!vd) - return; + return 0; desc = vd2dw_edma_desc(vd); if (!desc) - return; + return 0; child = list_first_entry_or_null(&desc->chunk->list, struct dw_edma_chunk, list); if (!child) - return; + return 0; dw_edma_v0_core_start(child, !desc->xfer_sz); desc->xfer_sz += child->ll_region.sz; @@ -206,6 +206,8 @@ static void dw_edma_start_transfer(struct dw_edma_chan *chan) list_del(&child->list); kfree(child); desc->chunks_alloc--; + + return 1; } static void dw_edma_device_caps(struct dma_chan *dchan, @@ -602,14 +604,17 @@ static void dw_edma_done_interrupt(struct dw_edma_chan *chan) switch (chan->request) { case EDMA_REQ_NONE: desc = vd2dw_edma_desc(vd); - if (desc->chunks_alloc) { - chan->status = EDMA_ST_BUSY; - dw_edma_start_transfer(chan); - } else { + if (!desc->chunks_alloc) { list_del(&vd->node); vchan_cookie_complete(vd); - chan->status = EDMA_ST_IDLE; } + + /* Continue to transfer in case of there are rest chunks, or issued + * requests remain. + */ + chan->status = EDMA_ST_BUSY; + if (!dw_edma_start_transfer(chan)) + chan->status = EDMA_ST_IDLE; break; case EDMA_REQ_STOP: From patchwork Fri Mar 17 11:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shunsuke Mie X-Patchwork-Id: 13178941 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 A2B24C6FD1D for ; Fri, 17 Mar 2023 11:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbjCQLeT (ORCPT ); Fri, 17 Mar 2023 07:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbjCQLeL (ORCPT ); Fri, 17 Mar 2023 07:34:11 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50CDA8E94 for ; Fri, 17 Mar 2023 04:33:34 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id qe8-20020a17090b4f8800b0023f07253a2cso4871851pjb.3 for ; Fri, 17 Mar 2023 04:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; t=1679052805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UBJ3jXvxXCld7rCbYIUA76P7q/tR6ahC8o8afEyFSeg=; b=SSqnByrqrr+3VcUDTYBw+VNwigK0LKtbr3MEmUWTApLPk2vh3j2tzaOsn1hq0KcVR6 6aivcKsqqMiMH9mvfQuEqYm0O3UlMzJZljBHtbwxrnu6mnC1tGsnMLZbXPpgxD9p+Ffp nYOXAWx+D3hwVjMftozRbucnIv5txD2FWVxIdqrst32Fi0o9zO5GKthRuetbfB/fVbgo WBNH7cRghUYZPLtkP27Cl7zlIJ9zANuuY6QLfMq/5gAdWra9LpfVDIrVEMATdFii7LhJ U4BrqaJR9u41RGSTvx7+bF/VSMvwLLvXVgrLa2caxXfPMckKLRNMsZmAoOWbBPH8pAeW mvtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679052805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UBJ3jXvxXCld7rCbYIUA76P7q/tR6ahC8o8afEyFSeg=; b=EynsE5p8D0PeANdHIT5mJ3rgZLGt0gBSLsZiMcdMMfNn6Xlor236I6RGsf1bDqjS+g 8Q9yC8yo9KykwbWXGkV+Kaa5Hy2eg+7B9qS4qTB/MFFTpYWiTHtT7ERZ4sC0Te86bw+H WQHnZDa1OpvRmQHKUmOORY5SzVjY2eiE+R7bskONhxFGTs3rtaxt26uWF6rh+RNedp5K nApjCkhhILOxa45YkpTzqKoqf9ISVzQfHBwgnTx0kfEHqrxSGrrQZ9h7A8N6Dm0eXzyY O2dh4owDxKIahPLyRgXWUwzNVNj5Fvibh+L7z799AFHwUIYusMkO8FGrfwTW+LvKshRc cYrg== X-Gm-Message-State: AO0yUKXo6yaZe4JUkq0JBAAm9Zf0/eqNgPGsAPS7amXW6Fwgwx/7hLWd noC5SO99iWxwDsUhX91C+jSpuA== X-Google-Smtp-Source: AK7set8mw4eu8SWp80RS17+P5NFx2EppFu4x7YobwRde2GI2yhM4sarU4Jk2ey0NmwtFezyvF659YQ== X-Received: by 2002:a17:90b:1b07:b0:23f:5247:3334 with SMTP id nu7-20020a17090b1b0700b0023f52473334mr3353989pjb.19.1679052804978; Fri, 17 Mar 2023 04:33:24 -0700 (PDT) Received: from tyrell.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id e3-20020a17090a818300b00233aacab89esm1182904pjn.48.2023.03.17.04.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 04:33:24 -0700 (PDT) From: Shunsuke Mie To: Gustavo Pimentel Cc: Vinod Koul , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , Shunsuke Mie , Kunihiko Hayashi , Yoshihiro Shimoda , Frank Li , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH 11/11] dmaengine: dw-edma: Fix to enable to issue dma request on DMA processing Date: Fri, 17 Mar 2023 20:32:38 +0900 Message-Id: <20230317113238.142970-12-mie@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230317113238.142970-1-mie@igel.co.jp> References: <20230317113238.142970-1-mie@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org The issue_pending request is ignored while driver is processing a DMA request. Fix to issue the pending requests on any dma channel status. Fixes: e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver") Signed-off-by: Shunsuke Mie --- drivers/dma/dw-edma/dw-edma-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index c527af00ff4e..430f9ee0d9e8 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -308,9 +308,12 @@ static void dw_edma_device_issue_pending(struct dma_chan *dchan) struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan); unsigned long flags; + if (!chan->configured) + return; + spin_lock_irqsave(&chan->vc.lock, flags); - if (chan->configured && chan->request == EDMA_REQ_NONE && - chan->status == EDMA_ST_IDLE && vchan_issue_pending(&chan->vc)) { + if (vchan_issue_pending(&chan->vc) && chan->request == EDMA_REQ_NONE && + chan->status == EDMA_ST_IDLE) { chan->status = EDMA_ST_BUSY; dw_edma_start_transfer(chan); }