Received: by 10.192.165.156 with SMTP id m28csp209882imm; Tue, 17 Apr 2018 08:53:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx49740t7rImvxRU2A3PEhyk7jwIWK3a//fb5jpaVlroxUkVxgFzX0xNZvlzaGzkhSbW6JdPF X-Received: by 2002:a17:902:20eb:: with SMTP id v40-v6mr2512675plg.277.1523980419394; Tue, 17 Apr 2018 08:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523980419; cv=none; d=google.com; s=arc-20160816; b=AaFMUG2EcpWUPk6nlf4lu0+NXzX7TPKIWlArVax+KQkP+0mwkEhUiUP+ZTN1NCPEr4 /CWhX9lID5gDzhsg211spaGR1fHi1zttmETzub4uGxNnZBt3N/swWh9Wwd5NLI58zJqf /ILR5y21CGSAvwgXVHEXq9gia/GFu99YB9Dm5RlnpOS7NImzmwJGThrCdjIAgXMXH5WO eWPT0bjr9UpCWYBR4DjT5sH9zBWcp6M70+5XbSTOwkIDupnEV/7M1wuLWdVFF1t7dvTg 2PtvpOok/Vore8/ZgftriWg9QdiLJE96fWFZQUDCE1wG2t8sAS4W0quC1phLPVMvF1eB utjA== 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:arc-authentication-results; bh=lRVwRtiTScwhmfcqDk+uyPsbtpJaozqV5B8WitzCUNE=; b=wMlLhgq7AVZG/bJc+ULvg/2ne5dr1HZrrfHMS6mruwZsRrAYQ429dEVwF/NokSEAFJ 18V7Zk5gM7UcSd11fDoUGskOAx9wStEzmDydhMvYq6KMC+egdXxUTZhg34Uk28M5Udj9 RVltsstaedQEf+udP9BQJJzcVYr3TxJkdSQnKM8OIxVeyhfzCNaowmsWZkZL2VWb3Evv m8ec7rfC3NwnfbQHCzTC9XuDRIPpQ7z/nRING9b+fIHS1s3TAl/fCJs22lNP0sjOHkbO sOaLPcVqWGjrvX9H9lQ5EeG5R2TjODcN/zlrlrnCfUnHSzpvoyMbWFrWAPMcpmistshJ bmlQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 c10-v6si14980049plr.398.2018.04.17.08.53.24; Tue, 17 Apr 2018 08:53:39 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546AbeDQPwN (ORCPT + 99 others); Tue, 17 Apr 2018 11:52:13 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:55680 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751187AbeDQPwM (ORCPT ); Tue, 17 Apr 2018 11:52:12 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 6993510C04BF; Tue, 17 Apr 2018 08:52:11 -0700 (PDT) Received: from pt02.synopsys.com (pt02.synopsys.com [10.107.23.240]) by mailhost.synopsys.com (Postfix) with ESMTP id A98033E79; Tue, 17 Apr 2018 08:52:10 -0700 (PDT) Received: from [127.0.0.1] (gustavo-e7480.internal.synopsys.com [10.107.25.102]) by pt02.synopsys.com (Postfix) with ESMTP id 088CF3EE20; Tue, 17 Apr 2018 16:52:10 +0100 (WEST) Subject: Re: [RFC 03/10] PCI: endpoint: Add MSI-X interfaces To: Kishon Vijay Abraham I , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "Joao.Pinto@synopsys.com" , "jingoohan1@gmail.com" , "adouglas@cadence.com" , "niklas.cassel@axis.com" , "jesper.nilsson@axis.com" Cc: "linux-pci@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <7fec2005-d7a8-daea-9451-7f3593afe285@ti.com> From: Gustavo Pimentel Message-ID: <27b67ebd-b585-f3a1-091d-a3cdf13f03eb@synopsys.com> Date: Tue, 17 Apr 2018 16:51:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <7fec2005-d7a8-daea-9451-7f3593afe285@ti.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kishon, On 17/04/2018 11:24, Kishon Vijay Abraham I wrote: > Hi, > > On Tuesday 10 April 2018 10:44 PM, Gustavo Pimentel wrote: >> Implements the generic method for calling the get/set callbacks. >> >> Adds the PCI_EPC_IRQ_MSIX type. >> >> Adds the MSI-X callbacks signatures to the ops structure. >> >> Adds sysfs interface for altering the number of MSI-X entries. >> >> Signed-off-by: Gustavo Pimentel >> --- >> drivers/pci/endpoint/pci-ep-cfs.c | 24 ++++++++++++++++ >> drivers/pci/endpoint/pci-epc-core.c | 57 +++++++++++++++++++++++++++++++++++++ >> include/linux/pci-epc.h | 11 ++++++- >> include/linux/pci-epf.h | 1 + >> 4 files changed, 92 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c >> index 018ea34..d1288a0 100644 >> --- a/drivers/pci/endpoint/pci-ep-cfs.c >> +++ b/drivers/pci/endpoint/pci-ep-cfs.c >> @@ -286,6 +286,28 @@ static ssize_t pci_epf_msi_interrupts_show(struct config_item *item, >> to_pci_epf_group(item)->epf->msi_interrupts); >> } >> >> +static ssize_t pci_epf_msix_interrupts_store(struct config_item *item, >> + const char *page, size_t len) >> +{ >> + u16 val; >> + int ret; >> + >> + ret = kstrtou16(page, 0, &val); >> + if (ret) >> + return ret; >> + >> + to_pci_epf_group(item)->epf->msix_interrupts = val; >> + >> + return len; >> +} >> + >> +static ssize_t pci_epf_msix_interrupts_show(struct config_item *item, >> + char *page) >> +{ >> + return sprintf(page, "%d\n", >> + to_pci_epf_group(item)->epf->msix_interrupts); >> +} >> + >> PCI_EPF_HEADER_R(vendorid) >> PCI_EPF_HEADER_W_u16(vendorid) >> >> @@ -327,6 +349,7 @@ CONFIGFS_ATTR(pci_epf_, subsys_vendor_id); >> CONFIGFS_ATTR(pci_epf_, subsys_id); >> CONFIGFS_ATTR(pci_epf_, interrupt_pin); >> CONFIGFS_ATTR(pci_epf_, msi_interrupts); >> +CONFIGFS_ATTR(pci_epf_, msix_interrupts); >> >> static struct configfs_attribute *pci_epf_attrs[] = { >> &pci_epf_attr_vendorid, >> @@ -340,6 +363,7 @@ static struct configfs_attribute *pci_epf_attrs[] = { >> &pci_epf_attr_subsys_id, >> &pci_epf_attr_interrupt_pin, >> &pci_epf_attr_msi_interrupts, >> + &pci_epf_attr_msix_interrupts, >> NULL, >> }; >> >> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c >> index b0ee427..294a383 100644 >> --- a/drivers/pci/endpoint/pci-epc-core.c >> +++ b/drivers/pci/endpoint/pci-epc-core.c >> @@ -218,6 +218,63 @@ int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) >> EXPORT_SYMBOL_GPL(pci_epc_set_msi); >> >> /** >> + * pci_epc_get_msix() - get the number of MSI-X interrupt numbers allocated >> + * @epc: the EPC device to which MSI-X interrupts was requested >> + * @func_no: the endpoint function number in the EPC device >> + * >> + * Invoke to get the number of MSI-X interrupts allocated by the RC >> + */ >> +int pci_epc_get_msix(struct pci_epc *epc, u8 func_no) >> +{ >> + int interrupt; >> + unsigned long flags; >> + >> + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) >> + return 0; >> + >> + if (!epc->ops->get_msix) >> + return 0; >> + >> + spin_lock_irqsave(&epc->lock, flags); >> + interrupt = epc->ops->get_msix(epc, func_no); >> + spin_unlock_irqrestore(&epc->lock, flags); >> + >> + if (interrupt < 0) >> + return 0; >> + >> + return interrupt++; > > return interrupt + 1? I'll change it. >> +} >> +EXPORT_SYMBOL_GPL(pci_epc_get_msix); >> + >> +/** >> + * pci_epc_set_msix() - set the number of MSI-X interrupt numbers required >> + * @epc: the EPC device on which MSI-X has to be configured >> + * @func_no: the endpoint function number in the EPC device >> + * @interrupts: number of MSI-X interrupts required by the EPF >> + * >> + * Invoke to set the required number of MSI-X interrupts. >> + */ >> +int pci_epc_set_msix(struct pci_epc *epc, u8 func_no, u16 interrupts) >> +{ >> + int ret; >> + unsigned long flags; >> + >> + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions || >> + interrupts < 1 || interrupts > 2048) >> + return -EINVAL; >> + >> + if (!epc->ops->set_msix) >> + return 0; >> + >> + spin_lock_irqsave(&epc->lock, flags); >> + ret = epc->ops->set_msix(epc, func_no, interrupts - 1); >> + spin_unlock_irqrestore(&epc->lock, flags); >> + >> + return ret; >> +} >> +EXPORT_SYMBOL_GPL(pci_epc_set_msix); >> + >> +/** >> * pci_epc_unmap_addr() - unmap CPU address from PCI address >> * @epc: the EPC device on which address is allocated >> * @func_no: the endpoint function number in the EPC device >> diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h >> index af657ca..32e8961 100644 >> --- a/include/linux/pci-epc.h >> +++ b/include/linux/pci-epc.h >> @@ -17,6 +17,7 @@ enum pci_epc_irq_type { >> PCI_EPC_IRQ_UNKNOWN, >> PCI_EPC_IRQ_LEGACY, >> PCI_EPC_IRQ_MSI, >> + PCI_EPC_IRQ_MSIX, >> }; >> >> /** >> @@ -30,6 +31,10 @@ enum pci_epc_irq_type { >> * capability register >> * @get_msi: ops to get the number of MSI interrupts allocated by the RC from >> * the MSI capability register >> + * @set_msix: ops to set the requested number of MSI-X interrupts in the >> + * MSI-X capability register >> + * @get_msix: ops to get the number of MSI-X interrupts allocated by the RC >> + * from the MSI-X capability register >> * @raise_irq: ops to raise a legacy or MSI interrupt >> * @start: ops to start the PCI link >> * @stop: ops to stop the PCI link >> @@ -48,8 +53,10 @@ struct pci_epc_ops { >> phys_addr_t addr); >> int (*set_msi)(struct pci_epc *epc, u8 func_no, u8 interrupts); >> int (*get_msi)(struct pci_epc *epc, u8 func_no); >> + int (*set_msix)(struct pci_epc *epc, u8 func_no, u16 interrupts); >> + int (*get_msix)(struct pci_epc *epc, u8 func_no); > > The 1st patch in the series is already using get_msix, set_msix. This patch > should precede the 1st patch. Yes, you're right. > > Thanks > Kishon > Regards, Gustavo