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: 13178930 X-Patchwork-Delegate: bhelgaas@google.com 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 5B473C6FD1D for ; Fri, 17 Mar 2023 11:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbjCQLcw (ORCPT ); Fri, 17 Mar 2023 07:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbjCQLcv (ORCPT ); Fri, 17 Mar 2023 07:32:51 -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 5071153281 for ; Fri, 17 Mar 2023 04:32:49 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id j13so4774588pjd.1 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=6SdY6aX4aKrRaAi7fEeqVLfzG4A8tUmdyOBQzHw9ul9DJiJJSjXFp4kYcnW5qvDPS1 eqtf0MhOmlpM2BxQ42aIszNd9Y+R4/sGBcyDUS5s/DpQ4fxDiGGXOA7Q9x2TNWvr8DUp rmNkwon89OoBFVXAaxGP9a6a/edFbXqZieiHcskge7RFsqQYVCQ7G63la317ZEk90thM 9ci4xJWqaZgQzk9LaiqQbHLP09rQikMFvkEiq6EsP8NPfyC6/OUG5iH3M2qpXLXLAQZJ 5nEB+/ENArOWlKN2rRJcsDodRtKlfU10b2uULnweOOzeWSB8WGZ8rVKRLauT9R5LS9cO MyJQ== X-Gm-Message-State: AO0yUKWcXiBwQc3eY5NVjVLGlZ3Sr+Ko8aIU1Gg/FTC6NqOgKJKW8S69 VsujmJaHg/LJz8kMnLUWTdAvbA== 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: linux-pci@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: 13178931 X-Patchwork-Delegate: bhelgaas@google.com 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 DB755C74A5B for ; Fri, 17 Mar 2023 11:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjCQLdF (ORCPT ); Fri, 17 Mar 2023 07:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbjCQLc5 (ORCPT ); Fri, 17 Mar 2023 07:32:57 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEACB90B76 for ; Fri, 17 Mar 2023 04:32:52 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id ix20so4987253plb.3 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=R3f1p6Va44a9/rCtUg76jC77yTTQHwgu5HvDIc+ojVpcSD62O9bCkD6QugSjuGbSbg vwPMMHn2UbemRfXOcIk2KLJhoQqIchm6a3Crox9QF6nyEKpYbg6vWvcisE6KlHVzBVmJ DqxNv5ZTNKT2qeFSwouRX58yfWkP8tikzmGSbjG2lDC7/1AKGyVmuxDr5UMpku1yhPPS 44szbS0wuk71igY2wMBDr0SbupjFFbyQTRhQWdRZPMaYnKuLtHD5nm1bjnedE2OUmPzU S4FhgKdA0aojNTrH0W/Q8dAAh6DQTl0H77KOIqi5AMaLA+rDZ7ZJcOo9VnxL/iiDMzBJ c97Q== X-Gm-Message-State: AO0yUKU07MNXQHY22ch76BMnRgqi3kWwZ1vBFWLin616aPDNuV/4LszO QDmFAM7fuC2SnIB1x2gUTGI7yg== 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: linux-pci@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: 13178932 X-Patchwork-Delegate: bhelgaas@google.com 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 47845C74A5B for ; Fri, 17 Mar 2023 11:33:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjCQLdK (ORCPT ); Fri, 17 Mar 2023 07:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjCQLdG (ORCPT ); Fri, 17 Mar 2023 07:33:06 -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 052ABA56BE for ; Fri, 17 Mar 2023 04:32:56 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id h8so4960552plf.10 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=SMIgmQtbtftCTxrpddK+2uEhE4F0xwTaYpW34CfIUsJ7V6Ha5s+Sv5AyDvulmesYQD 8mousSYPxtCnj0dk/Mf9YjMF6IdqwXxI6ESpqVYbav1C94nKe8bynfg7j9+jfpZUxhsn QldnFQUOSy54QnbvLxyJg7FE/n+25M9yIPNGyeXHTWXcXE1IYPBKEyqaRpePSVvV9TeW SJgLwtRljtQnga27aVc/S2W7oQOxHf7t7VddBqTCz6q/DKbImwc+OvqV4VaHBDhqMq0I Udaktp/NE4j4KbnJAO3UkGPJACd4/xJ+7/cVMs7gwQ7ljOXO58wsCaq6qQnOuo7IAYy5 N4pg== X-Gm-Message-State: AO0yUKUpEZzxW+m15H/exDk+3R7EMF1pcgUHhUwRblr6dThxzTktYcxl qCwapE/qDaWZwqCNp77QIRq9mQ== 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: linux-pci@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: 13178933 X-Patchwork-Delegate: bhelgaas@google.com 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 77386C6FD1D for ; Fri, 17 Mar 2023 11:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjCQLdS (ORCPT ); Fri, 17 Mar 2023 07:33:18 -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 S230063AbjCQLdI (ORCPT ); Fri, 17 Mar 2023 07:33:08 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A3C9A8C62 for ; Fri, 17 Mar 2023 04:33:00 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id qe8-20020a17090b4f8800b0023f07253a2cso4870700pjb.3 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=uhX8wYmVY+R1Bj2q/4gatLoFGLnnUR3Wc2HLo5WKfH0VhP4RluJDJh3z/98Luhvxrk lFlLCY+sRUlylvSi9unISJCdJiXxFzLRuecJ7UpHh4j8LUY8LdeM/wInuBBqQPcVOIQr 7KXCSWBEsfDDnN1yY7w6HIc3flEmMb2RBQmX3bkAwr5/Mh3jWdMNCnUbFMWUkxNm0XlE sNhQiajg0CDcpjv4Nza+im5WWkAsjrm7wRGVzHlAYP2Oevw/rbtzSzbRkamjA/TZh5Eg XNTpJVk7lJoeSKQxeaZRZtPAWDFnc4UbFOtrtJnxUFMNkp/kMxndHUxnMEJrkwE48N8m zB7w== X-Gm-Message-State: AO0yUKVr95vSws70qTCkQomB6FlrCDoVQd5jfdCphsVEyRGFhPl82TbW 7ar1nt/hEKZB3UqlDOoczRDzTw== 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: linux-pci@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: 13178942 X-Patchwork-Delegate: bhelgaas@google.com 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 D43A5C6FD1D for ; Fri, 17 Mar 2023 11:33:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbjCQLdZ (ORCPT ); Fri, 17 Mar 2023 07:33:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbjCQLdW (ORCPT ); Fri, 17 Mar 2023 07:33:22 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CB808C539 for ; Fri, 17 Mar 2023 04:33:04 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id p20so4955057plw.13 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=d8+nXsLImWyWayqhK0GbrlM0Xcbdm0ow9l/C2rVSuC5Np6E0UV3xYiIXsbkUwtUqiQ W8iXmYomddBRwzq82nx/3S3JbAmBPgCvjfc34wM84k7QXFnDGCfv4BHY4aLJdkrS77Zu roTaj/qyrxFhr2INeB91+HW2o6n751qdX88P7zcNFCZU5sN8Igh8c32BcR1CLmU2lxTg loDaRclLBbMm8iftLZlfA8yGwtBHJlpF/yVsTmYyKHQob9r0ieuyukG/ogGzqkS2K8Gf l4Yim0sILf1UZkZR5Mcgg3LGg3BBM0JXgPwEsQ2/EG6mpQoWaagZCJx3e8jv0XcMuCvv IY+A== X-Gm-Message-State: AO0yUKUhGrEmWZf7grmL326nuK4KYWTOpIEDmiRuBgPlydH5vl27Rzpn BgXNz26UqD8WG/MRWTlWjO3F/Q== 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: linux-pci@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: 13178943 X-Patchwork-Delegate: bhelgaas@google.com 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 CF0F6C6FD1D for ; Fri, 17 Mar 2023 11:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbjCQLdk (ORCPT ); Fri, 17 Mar 2023 07:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbjCQLdi (ORCPT ); Fri, 17 Mar 2023 07:33:38 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 234C2AA70C for ; Fri, 17 Mar 2023 04:33:08 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id j13so4775372pjd.1 for ; Fri, 17 Mar 2023 04:33:08 -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=v0UD/tuXvGFR0FBohmSjfzz/lmIZjj5rBd3r1mLd73peAMQdGVT2NeCY3wCjxdE2hr CJlruaDEGDskqnpMRHPqSZDSVl3bfri8zPIHEP4RDt+7wcCN1xu2QgFkcv+38OoH4F9w KATX9v++d994BCKZbpwpXB1uSlV5GWhZPJe2LIIjXvkJoG+HygtCvScg3QZ8t8kNHNZK m/XxTx1wPtvKZN+e169cd0pRNr7rJaFbpNOpa7uusj6+s1bZ6nhPLtPa08sQmyO5y+lq GtbpUQT9BX67VSZo57+WrbJk3w35ZTXdqDdkKkISzB4Msj+y9l5soSRBsEZ6yczvpPc2 GM6w== X-Gm-Message-State: AO0yUKUjX25Ogs6lRw/ossCubBUeBF87NK/kPIg0rSocdRZK8XwmwwFI Bb8A8StItISdY3VbOj8aB9zTTw== 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: linux-pci@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: 13178944 X-Patchwork-Delegate: bhelgaas@google.com 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 0342AC6FD1D for ; Fri, 17 Mar 2023 11:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbjCQLds (ORCPT ); Fri, 17 Mar 2023 07:33:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjCQLdr (ORCPT ); Fri, 17 Mar 2023 07:33:47 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA166A1FF0 for ; Fri, 17 Mar 2023 04:33:11 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id iw3so4975522plb.6 for ; Fri, 17 Mar 2023 04:33:11 -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=yVR5OovwTSpvt0CuCiey51q164TZmVXdqz9n/JmV/ejcl/9No3/KU4rS7+VGRM51v3 Nv20Gt+Qy0Kkpk4iDnyPs2TAXqLvJnsCGV4rUOjNu2VXS//4ZIFxiYrWmMKUgK4P+Ogi HLHxs7hN5scn5XqJYlL8vfcBTF8PCvT1uLngr7b4jaj0hDd0Abv8Lvwf0N8TiICiU55c eKg/HmhZ8CvXxdAUlRxzpUhWtooGHXKePY/Eaom6pAnpMyuRxhEKquCIVpbZaU0l9D8g pYp8n0GUseDLkkJCeMMeUtldev25O3/3zXvTCj4TJgMjkhnFLGrEMnpEWlSef3YnARaI 6WMg== X-Gm-Message-State: AO0yUKU5wUbJBFpPq4VO91S8qCZeUVo75uhMHocK3n3bQYFVJe4nr1LR O+zTL1U2dH5ZHjiELYJjaCkPjA== 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: linux-pci@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: 13178945 X-Patchwork-Delegate: bhelgaas@google.com 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 41944C6FD1D for ; Fri, 17 Mar 2023 11:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbjCQLdz (ORCPT ); Fri, 17 Mar 2023 07:33:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjCQLdw (ORCPT ); Fri, 17 Mar 2023 07:33:52 -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 CA031ACE02 for ; Fri, 17 Mar 2023 04:33:14 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id v21so4966227ple.9 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=rv3DiEXziqMbbNiLHVKii/3AHfe5GfR2dZtvLn0bNs0txtVTITvL9asM+bcWBk79uH Sxj2EF9Te6QvDtNzk/7Q+8W3IRey4bPIWjoD++iy1DRc8D/St50xRkiqQzlKO4IB7Xyl S3unmn8Yl7opg9aRkVJynWibSVfuJliCtCdH48iJ2g2O4ulY8PrCIkTy5xWLIxqe4N5x K1A7y7t0ZYDmELCpB1i8pEebr+votbZQUpPckwZf1YvSuW8P5ua8HMM57tIPCYxrWo4l QMWvWcId0JTvaO1l8Tbtj8ucEyhOGiUjkmK9mEmRTYdtzQM6nqXss7DXOWyhg4f7NEkW 75SA== X-Gm-Message-State: AO0yUKVr3LrQv7MyGL0TLTIhz7vuX7wsDuP6Rr63eEdZAeHrwXrnAeH7 w/vMdxcNJUwBcjugSV0z8BqAXg== 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: linux-pci@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: 13178946 X-Patchwork-Delegate: bhelgaas@google.com 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 8AD3EC6FD1D for ; Fri, 17 Mar 2023 11:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbjCQLeA (ORCPT ); Fri, 17 Mar 2023 07:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjCQLd7 (ORCPT ); Fri, 17 Mar 2023 07:33:59 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F56DA6BC3 for ; Fri, 17 Mar 2023 04:33:18 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id x11so2853505pja.5 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=vKX3zE6Y4kmM+Tbi4kcWz9eKEKTi6PopoLv/AB8QGF2ei/70eAYZm3judFMyQx7v6e 0hlX5GyJz2/5wCGRqX58rM1ktPoGt+1/xtkf2TuLB3nOkJFWe6KErIxiF4aMpu555uG6 hqlU+C8YJIApgN4LzmdDLfBpq5OVvzAJdU/6x7LZ09pRJtXoH+QbEmeOyX2pKm9/85Uo DIRFT3POR4qf3Z6zhQUzHE7d9iFSYxHr7CK6n9PSzU3lC5yl+vOSOeyTveuecBAy4iWe b6X51VcBMdCZi0TVF2I86fAga/a1rJJTJMl2cDWxJo435BkV17RZFlpaf6EuplbOYvqv GEDg== X-Gm-Message-State: AO0yUKW1gSk0EuN5xr9wNPGrDDwzPQ3/fog8MJE14dlRxOkJSHYK4AJV Zef7q+3bobVIHSkQGdsDcfOyHw== 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: linux-pci@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: 13178947 X-Patchwork-Delegate: bhelgaas@google.com 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 617ACC74A5B for ; Fri, 17 Mar 2023 11:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbjCQLeK (ORCPT ); Fri, 17 Mar 2023 07:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjCQLeH (ORCPT ); Fri, 17 Mar 2023 07:34:07 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB2ED90B76 for ; Fri, 17 Mar 2023 04:33:26 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id j3-20020a17090adc8300b0023d09aea4a6so8756429pjv.5 for ; Fri, 17 Mar 2023 04:33:26 -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=5YJfK5AmLWD6mWa3IcVCM2zwcb/OPoWj2O6drLB2uhD+03bug1a/fJpIG7iBqI3e8j tIcGNSwIbSNQM9JCG0bKWbJMhDr6/C4bU9mQvumU5buzBroZUsRSOC6tJpvZxpFUV6sI Hjxh00k2YjrLO1pUIj0ONNAXpVc+QLSv3Lfc+U6/raBXp8yg1zTTPUubaD9Y26QXHzqp 3tZRy+s2CKmOt2QCxphx2Jddt+vw7pd8H2zNtvGDqNIRs1srW4BSTmFRuFCPiSNK1aBa MMstvTf2ANqsQBcYcL7ze1RONvDUDd83VJpLvMn86E1WPb58q83n3rJG15uAGPu0HWZB cjnQ== X-Gm-Message-State: AO0yUKWT/0SOUVw6LMHapE4/jiSmIE9AW4L+VOjczR7ctfO+bY8GLARb P6yh6j8UvX1G7akjheIRPyNiFg== 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: linux-pci@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: 13178948 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 1ADEAC74A5B for ; Fri, 17 Mar 2023 11:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbjCQLeU (ORCPT ); Fri, 17 Mar 2023 07:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjCQLeM (ORCPT ); Fri, 17 Mar 2023 07:34:12 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C55A8E97 for ; Fri, 17 Mar 2023 04:33:35 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id j3-20020a17090adc8300b0023d09aea4a6so8756597pjv.5 for ; Fri, 17 Mar 2023 04:33:35 -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=HJeD5NpYwcThBmIDhpihfzYyB32YGfBeVVGnydCAVxjJUI7bRNuomPZ73Tn3W0lmce 2q+MDnctTxvu0u06k1OKwBSnDwpHHVV68XLeHh4IVwoULoIYdxhcBK3DurBUl/aHlVgs t69OGULHEdrXd/VuNfY6LWq5TS7kgrACyfQk2Vg/3wG6sbpk+p6w1ne6wClgY4CNtF7u vUIYcTxSRC1G1bgviuFwBHAWgiRJuw2kb/TMgo87llaZbt8NK6MBZvB+wJDW2zT3MdrL ET6H6wvhY16OVV8VRpcwowRCHpeLkXluDTYiGkGbGvsUoqPOeYC9Q6MziA7DIW10h/DU fAPg== X-Gm-Message-State: AO0yUKX4dsuyYWbpyohoFhQSXsmkOdk1xwuXgU2jmpxXL7aTdB4AsH1q URWfpGcJZzbtx80n/0pJJA+wAg== 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: linux-pci@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); }