From mboxrd@z Thu Jan 1 00:00:00 1970 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 B5720CA0FF6 for ; Sat, 2 Sep 2023 05:12:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351513AbjIBFML (ORCPT ); Sat, 2 Sep 2023 01:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240011AbjIBFML (ORCPT ); Sat, 2 Sep 2023 01:12:11 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B4CE1702 for ; Fri, 1 Sep 2023 22:12:08 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68c576d35feso2292248b3a.2 for ; Fri, 01 Sep 2023 22:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693631527; x=1694236327; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=r8vaSTPW9tq/2PvzUS7UQE38t7wNIDxl1GYzejiN7sk=; b=LYrEmEemuCK7BWJly5+ccV0sZZHUzuYd4THosOI2kJtDX9v6/pvqFYtCL7GSVY2CqT 3SPRunvEeuSVtcptlQb10p+10cuFeTb/feHfCmGgYvtA4tun4GsPnqoRoZ/FLsMhUfXj Hkt4WGKeMJA5RdC9rnZipkgAN9Q0X7/Dy/iYueIkyU/Mpn0KPJfkELrYzS7fX+mD1io/ DdRogJVz+1DvKfhlDZ9PNDCOiC4hSmOqZtYg4MT72yTyILQLnw1pyy78PZtVC4W/k7aZ 1f/BTOFoMo3qydxLfCbVkVklZIsvHQ7UFpgKEkGLzvt0/TKFy54DRW2TU2pF45fHumBZ qaUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693631527; x=1694236327; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r8vaSTPW9tq/2PvzUS7UQE38t7wNIDxl1GYzejiN7sk=; b=Mge9f90bDK/BcL5JNaiO0BxROLk2w3bvlg1WAGabQ4I6hWOAvP0BRDeT4uOUp6dwEv F5OyxRgvV5T2upvkrwdPPPqlRD91y+K7ZjjI6czel1fL604vtrP4myp5yji7ihjRj93X ACui5svLL0vBYpWM6YkXW+LAmLhb5GpD+Bv8H5PbNIdU/aoU5WOJrXHjPRGrzeUrGncu Zat9RDTPPb0nfICjFVwDwijGNcqUlS/TfB+RMKdC7zD7miAmquQ71G/rlHwmMdZMkefg UBj9fhUlSOEM239LU+UQbA8ZKO5a3d7snJca8mK7Is4UHoYvrsEH38TGArL/reLre+v7 ww9Q== X-Gm-Message-State: AOJu0Yw8hEjddd3dBH92GsifYPqugFUWJQ9UNT0LAqAYdXP6o5Hsdcuu 2q+nZZ08DJCvYlQTPJxM2rX2 X-Google-Smtp-Source: AGHT+IHgsXpqTNSkB6YwoRAaMwF4G43/AdpXBzgcVLTWHC96ohQGa3KhTjGgDtkfaxi1IoC3pHwD6A== X-Received: by 2002:a05:6a20:938d:b0:138:64d4:b055 with SMTP id x13-20020a056a20938d00b0013864d4b055mr5948002pzh.55.1693631527333; Fri, 01 Sep 2023 22:12:07 -0700 (PDT) Received: from thinkpad ([117.217.187.8]) by smtp.gmail.com with ESMTPSA id k188-20020a636fc5000000b0055bf13811f5sm3658873pgc.15.2023.09.01.22.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 22:12:06 -0700 (PDT) Date: Sat, 2 Sep 2023 10:41:55 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: tglx@linutronix.de, aisheng.dong@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, festevam@gmail.com, imx@lists.linux.dev, jdmason@kudzu.us, kernel@pengutronix.de, kishon@ti.com, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, maz@kernel.org, ntb@lists.linux.dev, peng.fan@nxp.com, robh+dt@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: Re: [PATCH 2/3] misc: pci_endpoint_test: Add doorbell test case Message-ID: <20230902051155.GC2913@thinkpad> References: <20230426203436.1277307-1-Frank.Li@nxp.com> <20230426203436.1277307-3-Frank.Li@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230426203436.1277307-3-Frank.Li@nxp.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Wed, Apr 26, 2023 at 04:34:35PM -0400, Frank Li wrote: > Reused flags as capability register in pci_endpoint_test struct to > support older driver versions. Save capability flags to 'cap' field > of struct pci_endpoint_test to prevent reading non-existent address. > This won't work, please see below. > Add three registers: PCIE_ENDPOINT_TEST_DB_BAR, PCIE_ENDPOINT_TEST_DB_ADDR, > PCIE_ENDPOINT_TEST_DB_DATA. > > Write data from PCI_ENDPOINT_TEST_DB_DATA to address from > PCI_ENDPOINT_TEST_DB_ADDR to trigger doorbell and wait for remote > endpoint feedback. "wait for endpoint response" > > Signed-off-by: Frank Li > --- > drivers/misc/pci_endpoint_test.c | 41 ++++++++++++++++++++++++++++++++ > include/uapi/linux/pcitest.h | 1 + > 2 files changed, 42 insertions(+) > > diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c > index ed4d0ef5e5c3..3320a3334594 100644 > --- a/drivers/misc/pci_endpoint_test.c > +++ b/drivers/misc/pci_endpoint_test.c > @@ -52,6 +52,7 @@ > #define STATUS_IRQ_RAISED BIT(6) > #define STATUS_SRC_ADDR_INVALID BIT(7) > #define STATUS_DST_ADDR_INVALID BIT(8) > +#define STATUS_DOORBELL_SUCCESS BIT(9) > > #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c > #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 > @@ -66,7 +67,12 @@ > #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 > > #define PCI_ENDPOINT_TEST_FLAGS 0x2c > +#define PCI_ENDPOINT_TEST_DB_BAR 0x30 > +#define PCI_ENDPOINT_TEST_DB_ADDR 0x34 > +#define PCI_ENDPOINT_TEST_DB_DATA 0x38 > + > #define FLAG_USE_DMA BIT(0) > +#define FLAG_SUPPORT_DOORBELL BIT(1) > > #define PCI_DEVICE_ID_TI_AM654 0xb00c > #define PCI_DEVICE_ID_TI_J7200 0xb00f > @@ -102,6 +108,7 @@ enum pci_barno { > BAR_3, > BAR_4, > BAR_5, > + NO_BAR = -1, > }; > > struct pci_endpoint_test { > @@ -118,6 +125,7 @@ struct pci_endpoint_test { > enum pci_barno test_reg_bar; > size_t alignment; > const char *name; > + u32 cap; > }; > > struct pci_endpoint_test_data { > @@ -713,6 +721,35 @@ static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test, > return false; > } > > +static bool pci_endpoint_test_doorbell(struct pci_endpoint_test *test) > +{ > + enum pci_barno bar; > + u32 data; > + u32 addr; > + > + if (!(test->cap & FLAG_SUPPORT_DOORBELL)) > + return false; > + > + bar = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); > + if (bar == NO_BAR) > + return false; Is this possible? > + > + data = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_DATA); > + addr = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_ADDR); > + bar = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); > + > + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS, 0); > + pci_endpoint_test_bar_writel(test, bar, addr, data); >From patch 1, I understood that EP supports multiple doorbell. But you are not making use of it here? > + > + wait_for_completion(&test->irq_raised); > + No timeout? > + data = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); > + if (data & STATUS_DOORBELL_SUCCESS) Please use a separate variable. > + return true; > + > + return false; > +} > + > static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, > unsigned long arg) > { > @@ -760,6 +797,9 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, > case PCITEST_CLEAR_IRQ: > ret = pci_endpoint_test_clear_irq(test); > break; > + case PCITEST_DOORBELL: > + ret = pci_endpoint_test_doorbell(test); > + break; > } > > ret: > @@ -887,6 +927,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, > misc_device->parent = &pdev->dev; > misc_device->fops = &pci_endpoint_test_fops; > > + test->cap = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_FLAGS); This register will be overwritten by this driver during (copy,read,write) tests. So this logic will not work. - Mani > err = misc_register(misc_device); > if (err) { > dev_err(dev, "Failed to register device\n"); > diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h > index f9c1af8d141b..479ca1aa3ae0 100644 > --- a/include/uapi/linux/pcitest.h > +++ b/include/uapi/linux/pcitest.h > @@ -20,6 +20,7 @@ > #define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) > #define PCITEST_GET_IRQTYPE _IO('P', 0x9) > #define PCITEST_CLEAR_IRQ _IO('P', 0x10) > +#define PCITEST_DOORBELL _IO('P', 0x11) > > #define PCITEST_FLAGS_USE_DMA 0x00000001 > > -- > 2.34.1 > -- மணிவண்ணன் சதாசிவம்