Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp793351imm; Mon, 9 Jul 2018 10:43:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfHxgcpH6nyA5RuU+O9gupY/BhRQek/8HxzU8vAsubrPbXV3ge7qup1p0XaCOKYnJbBjpyL X-Received: by 2002:a62:5d55:: with SMTP id r82-v6mr13413809pfb.150.1531158225028; Mon, 09 Jul 2018 10:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531158225; cv=none; d=google.com; s=arc-20160816; b=fNqGfp3m8l1b409cu1oHfgTM8D4yqq/V3qDKhDCxg6FG+CGgFlSneXJqdHMqfNCEK+ /XWfZ5rPvpl214liUayBSTzFr/5pNC9OKtITigqYjtVM1yIJfoH73AXrwwjRDG0gxgv7 kz9HZgdtQSe+9lRqt/v4mBP6/i/E6kjcwhckXSXmb6J1ekjqcQS0tRk/tRg0mE+1TEEb fQHGpyQ53qIsNBfNgRLeDxjT+3lUIieA9YFT6b7qYLtugHS0WXiNXQMbiVwigH76rq9X AD0YUIO6rFGCladND5UYiHqBisMrvE1G1pdq062aWFmk5vLlyLGQ9lrQ5I+woQKON+4l nHOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Cg8hplnrwH2UT8XbfyOX41OWDmRzQTy45cQCRUn5YU0=; b=d9OReWGIEt6m9cz43P+4vG/oRRc31miygjaFz/q5AgOA1EYmNDAX76sR/zeEtBDc8n cRMJJK77f2jW4jkPGA6kMAB+UCKvin+qt3h3vHWT7aqpHoBmGdR/FETTY/PrX5Wni0X6 j6TbXPXJFmVA4sUsuCLEPu7r20JDC70h80qOYiSF3kK51F57OAAl0hy8uyWf4juhoY9F q9GeZuGoCE2wa/dNhUk982ymKakBsklNRK202XOh75zSSYAYJI4mGhPdhTvXP5TvFtUc RVkv8KN2zixA2UmBPG43AQcnZDLRfaQnzikO70d5OYqA3uNJj0NDnnHRoHOTfbDU4g22 BVmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=U5S33Z7h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g35-v6si12020978pgm.54.2018.07.09.10.43.30; Mon, 09 Jul 2018 10:43:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=U5S33Z7h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933861AbeGIRmW (ORCPT + 99 others); Mon, 9 Jul 2018 13:42:22 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:56651 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933607AbeGIRmU (ORCPT ); Mon, 9 Jul 2018 13:42:20 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id CC28010C1AF0; Mon, 9 Jul 2018 10:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1531158140; bh=OU/FVqcTqGyOZBbkh80dnwspjmXyiz6z1WcwoqKk8UU=; h=Subject:To:CC:References:From:Date:In-Reply-To:From; b=U5S33Z7hkFidxGG7y0TqVyBzWte7lp/2UQ7Lk4iVl8EhwIpq5DWpkXam66IdYzQlD W+1B59INeC7LX7wNRaGA6a6dtXWEL4dqTiXZS26xA1T7P1plkKXGBYfozNU5nKfQtI V2Co6x4FIMKXr55C7DZw6AMSEYmf8L18/T7gWZuSTFSTgAgis505yWesfcIJjI6Ibm OCAA2S11qXWW/v6nvhxFnoCicdHH+tJ+GBnmrR5gMZ01nwVsQkf6nK5m2IiiHoH4k1 HBQ1M0mRAfe9hHez8mcASyqCiZls2XeExCVgQIkGKfWXE3IYKbAVZHevPuunsya3fn 7VBKZjUxUU0nA== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) by mailhost.synopsys.com (Postfix) with ESMTP id 72566552C; Mon, 9 Jul 2018 10:42:19 -0700 (PDT) Received: from DE02WEHTCA.internal.synopsys.com (10.225.19.92) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 9 Jul 2018 10:42:19 -0700 Received: from DE02WEHTCB.internal.synopsys.com (10.225.19.94) by DE02WEHTCA.internal.synopsys.com (10.225.19.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 9 Jul 2018 19:42:15 +0200 Received: from [10.107.25.102] (10.107.25.102) by DE02WEHTCB.internal.synopsys.com (10.225.19.80) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 9 Jul 2018 19:42:15 +0200 Subject: Re: [PATCH v8 08/11] pci-epf-test/pci_endpoint_test: Add MSI-X support To: Kishon Vijay Abraham I , Gustavo Pimentel , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "Joao.Pinto@synopsys.com" , "jingoohan1@gmail.com" , "adouglas@cadence.com" , "jesper.nilsson@axis.com" , "shawn.lin@rock-chips.com" CC: "linux-pci@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <7bc01ee7-0645-0dcb-c74d-da3937e7d4a5@ti.com> From: Gustavo Pimentel Message-ID: Date: Mon, 9 Jul 2018 18:40:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: <7bc01ee7-0645-0dcb-c74d-da3937e7d4a5@ti.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.107.25.102] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 09/07/2018 11:26, Kishon Vijay Abraham I wrote: > Hi, > > On Monday 09 July 2018 03:38 PM, Gustavo Pimentel wrote: >> Hi, >> >> On 09/07/2018 05:48, Kishon Vijay Abraham I wrote: >>> Hi, >>> >>> On Friday 06 July 2018 09:21 PM, Gustavo Pimentel wrote: >>>> Add MSI-X support and update driver documentation accordingly. >>>> >>>> Signed-off-by: Gustavo Pimentel >>>> --- >>>> Change v2->v3: >>>> - New patch file created base on the previous patch >>>> "misc: pci_endpoint_test: Add MSI-X support" patch file following >>>> Kishon's suggestion. >>>> Change v3->v4: >>>> - Rebased to Lorenzo's master branch v4.18-rc1. >>>> Change v4->v5: >>>> - Nothing changed, just to follow the patch set version. >>>> Change v5->v6: >>>> - Moved PCITEST_MSIX ioctl entry from patch #10 to here. >>>> - Documented ioctl parameter type associated to >>>> drivers/misc/pci_endpoint_test.c driver. >>>> Change v6->v7: >>>> - Updated documentation. >>>> - Added flag that enables or not the MSI-X on the EP features. >>>> Change v7->v8: >>>> - Re-sending the patch series. >>>> >>>> Documentation/PCI/endpoint/pci-test-function.txt | 2 +- >>>> Documentation/ioctl/ioctl-number.txt | 1 + >>>> Documentation/misc-devices/pci-endpoint-test.txt | 3 +++ >>>> drivers/misc/pci_endpoint_test.c | 29 +++++++++++++++++------- >>>> drivers/pci/controller/dwc/pcie-designware-ep.c | 1 + >>>> drivers/pci/endpoint/functions/pci-epf-test.c | 29 ++++++++++++++++++++++-- >>>> include/linux/pci-epc.h | 1 + >>>> include/uapi/linux/pcitest.h | 1 + >>>> 8 files changed, 56 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/Documentation/PCI/endpoint/pci-test-function.txt b/Documentation/PCI/endpoint/pci-test-function.txt >>>> index 7ee2361..b1cbff3 100644 >>>> --- a/Documentation/PCI/endpoint/pci-test-function.txt >>>> +++ b/Documentation/PCI/endpoint/pci-test-function.txt >>>> @@ -34,7 +34,7 @@ that the endpoint device must perform. >>>> Bitfield Description: >>>> Bit 0 : raise legacy IRQ >>>> Bit 1 : raise MSI IRQ >>>> - Bit 2 : raise MSI-X IRQ (reserved for future implementation) >>>> + Bit 2 : raise MSI-X IRQ >>>> Bit 3 : read command (read data from RC buffer) >>>> Bit 4 : write command (write data to RC buffer) >>>> Bit 5 : copy command (copy data from one RC buffer to another >>>> diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt >>>> index 480c860..65259d4 100644 >>>> --- a/Documentation/ioctl/ioctl-number.txt >>>> +++ b/Documentation/ioctl/ioctl-number.txt >>>> @@ -166,6 +166,7 @@ Code Seq#(hex) Include File Comments >>>> 'P' all linux/soundcard.h conflict! >>>> 'P' 60-6F sound/sscape_ioctl.h conflict! >>>> 'P' 00-0F drivers/usb/class/usblp.c conflict! >>>> +'P' 01-07 drivers/misc/pci_endpoint_test.c conflict! >>>> 'Q' all linux/soundcard.h >>>> 'R' 00-1F linux/random.h conflict! >>>> 'R' 01 linux/rfkill.h conflict! >>>> diff --git a/Documentation/misc-devices/pci-endpoint-test.txt b/Documentation/misc-devices/pci-endpoint-test.txt >>>> index 4ebc359..fdfa0f6 100644 >>>> --- a/Documentation/misc-devices/pci-endpoint-test.txt >>>> +++ b/Documentation/misc-devices/pci-endpoint-test.txt >>>> @@ -10,6 +10,7 @@ The PCI driver for the test device performs the following tests >>>> *) verifying addresses programmed in BAR >>>> *) raise legacy IRQ >>>> *) raise MSI IRQ >>>> + *) raise MSI-X IRQ >>>> *) read data >>>> *) write data >>>> *) copy data >>>> @@ -25,6 +26,8 @@ ioctl >>>> PCITEST_LEGACY_IRQ: Tests legacy IRQ >>>> PCITEST_MSI: Tests message signalled interrupts. The MSI number >>>> to be tested should be passed as argument. >>>> + PCITEST_MSIX: Tests message signalled interrupts. The MSI-X number >>>> + to be tested should be passed as argument. >>>> PCITEST_WRITE: Perform write tests. The size of the buffer should be passed >>>> as argument. >>>> PCITEST_READ: Perform read tests. The size of the buffer should be passed >>>> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c >>>> index 349794c..f4fef10 100644 >>>> --- a/drivers/misc/pci_endpoint_test.c >>>> +++ b/drivers/misc/pci_endpoint_test.c >>>> @@ -39,13 +39,14 @@ >>>> >>>> #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) >>>> -/* BIT(2) is reserved for raising MSI-X IRQ command */ >>>> +#define COMMAND_RAISE_MSIX_IRQ BIT(2) >>>> #define COMMAND_READ BIT(3) >>>> #define COMMAND_WRITE BIT(4) >>>> #define COMMAND_COPY BIT(5) >>>> @@ -84,7 +85,7 @@ MODULE_PARM_DESC(no_msi, "Disable MSI interrupt in pci_endpoint_test"); >>>> >>>> static int irq_type = IRQ_TYPE_MSI; >>>> module_param(irq_type, int, 0444); >>>> -MODULE_PARM_DESC(irq_type, "IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI)"); >>>> +MODULE_PARM_DESC(irq_type, "IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI, 2 - MSI-X)"); >>>> >>>> enum pci_barno { >>>> BAR_0, >>>> @@ -202,16 +203,18 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) >>>> } >>>> >>>> static bool pci_endpoint_test_msi_irq(struct pci_endpoint_test *test, >>>> - u8 msi_num) >>>> + u16 msi_num, bool msix) >>>> { >>>> u32 val; >>>> struct pci_dev *pdev = test->pdev; >>>> >>>> pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, >>>> - IRQ_TYPE_MSI); >>>> + msix == false ? IRQ_TYPE_MSI : >>>> + IRQ_TYPE_MSIX); >>>> pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, msi_num); >>>> pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, >>>> - COMMAND_RAISE_MSI_IRQ); >>>> + msix == false ? COMMAND_RAISE_MSI_IRQ : >>>> + COMMAND_RAISE_MSIX_IRQ); >>>> val = wait_for_completion_timeout(&test->irq_raised, >>>> msecs_to_jiffies(1000)); >>>> if (!val) >>>> @@ -456,7 +459,8 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, >>>> ret = pci_endpoint_test_legacy_irq(test); >>>> break; >>>> case PCITEST_MSI: >>>> - ret = pci_endpoint_test_msi_irq(test, arg); >>>> + case PCITEST_MSIX: >>>> + ret = pci_endpoint_test_msi_irq(test, arg, cmd == PCITEST_MSIX); >>>> break; >>>> case PCITEST_WRITE: >>>> ret = pci_endpoint_test_write(test, arg); >>>> @@ -542,6 +546,12 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, >>>> dev_err(dev, "Failed to get MSI interrupts\n"); >>>> test->num_irqs = irq; >>>> break; >>>> + case IRQ_TYPE_MSIX: >>>> + irq = pci_alloc_irq_vectors(pdev, 1, 2048, PCI_IRQ_MSIX); >>>> + if (irq < 0) >>>> + dev_err(dev, "Failed to get MSI-X interrupts\n"); >>>> + test->num_irqs = irq; >>>> + break; >>>> default: >>>> dev_err(dev, "Invalid IRQ type selected\n"); >>>> } >>>> @@ -558,8 +568,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, >>>> pci_endpoint_test_irqhandler, >>>> IRQF_SHARED, DRV_MODULE_NAME, test); >>>> if (err) >>>> - dev_err(dev, "failed to request IRQ %d for MSI %d\n", >>>> - pci_irq_vector(pdev, i), i + 1); >>>> + dev_err(dev, "Failed to request IRQ %d for MSI%s %d\n", >>>> + pci_irq_vector(pdev, i), >>>> + irq_type == IRQ_TYPE_MSIX ? "-X" : "", i + 1); >>>> } >>>> >>>> for (bar = BAR_0; bar <= BAR_5; bar++) { >>>> @@ -625,6 +636,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, >>>> >>>> err_disable_msi: >>>> pci_disable_msi(pdev); >>>> + pci_disable_msix(pdev); >>>> pci_release_regions(pdev); >>>> >>>> err_disable_pdev: >>>> @@ -656,6 +668,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev) >>>> for (i = 0; i < test->num_irqs; i++) >>>> devm_free_irq(&pdev->dev, pci_irq_vector(pdev, i), test); >>>> pci_disable_msi(pdev); >>>> + pci_disable_msix(pdev); >>>> pci_release_regions(pdev); >>>> pci_disable_device(pdev); >>>> } >>>> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c >>>> index 70d0688..36d83d1 100644 >>>> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c >>>> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c >>>> @@ -585,6 +585,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) >>>> ep->msix_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSIX); >>>> >>>> epc->features = EPC_FEATURE_NO_LINKUP_NOTIFIER; >>>> + epc->features |= EPC_FEATURE_MSIX_AVAILABLE; >>> >>> This indicates all vendors of designware has MSIX enabled which is not true. >>> We'll need more logic than that. >> >> You mentioned and excellent point. Any particularity related to this features >> should be implemented each specific driver (in this case on >> pcie-designware-plat.c file). >> >> And by looking at this code now that you mentioned, I think the line code >> "epc->features = EPC_FEATURE_NO_LINKUP_NOTIFIER;" was added by mistake, if I >> remember well by default the linkup notification is expected, right? > > right, since dra7x was the first platform to have EP support added and it has > linkup notification mechanism. >> >> If I'm right, I may create an extra patch removing this 2 lines, do you agree? I will send a patch as soon as possible to fix this nasty bug. Unfortunately it will be more than just deleting 2 lines.... > > Agree. I think we should use ->ep_init() present in dw_pcie_ep_ops for > populating features. ->ep_init() right now is called in dw_pcie_ep_init() which > is not needed. Stuffs that are right now done in ->ep_init callbacks can be > done even before invoking dw_pcie_ep_init(). I don't think so, that we can invoke before, dw_pcie_ep_init() is responsible for creating the epc object and set the object address to the epc pointer present on the ep struct. This pointer is used later to access and set the feature field. > > We might have to add a new API pci_epc_init() to be invoked from function > driver, which should invoke ->ep_init() callback. The features of a particular > platform should be populated here. My solution for now is to repair this damage as soon as possible, for that I'll move the the feature setting from the pcie-designware-ep.c to the pcie-designware-plat.c and change some code order to work. I propose we implement this change after this patch has entered, otherwise we'll be adding yet another degree of complexity to this series, already quite complex. Can you test the the patch series v9 on your side Kishon? Regards, Gustavo > > Thanks > Kishon >