Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp445332imm; Thu, 31 May 2018 03:31:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLjSykX5PuA3BvlvAtTdbqPgdcMBBSEo9z8NXb+wPAsO2rqyacF5Osfonzozg2eJ3ZhsTzI X-Received: by 2002:a63:6ec6:: with SMTP id j189-v6mr4975722pgc.71.1527762666368; Thu, 31 May 2018 03:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527762666; cv=none; d=google.com; s=arc-20160816; b=zloihq7W0zmw+5FubfvkqLrZdes2T3Fof9mMtrAqXoOmMaE8Hhi5dooj/OW1S7+str tJdqaT1ivrw+1648pK1dsy7TAHOhZ4Bx5Zec3KzPwhmWqMme4faPlRbUwR3L9tY2NSYb ww+tnjU64Nq5jJ3awBLR2CW9cssI9KOD8B3nRfWA+dAT8hZE2T6Eb0gnTjQq/nYBdwpx 8AI0vU7un7+70G3NKwJop5PoXi7xyb2qkpkLXtkav5ddMOg/zfIzG6iO472061Sv9T4c W5QLfi3b41+ukDPBIsdV1WMZDPPh6l9tz+QJQbCDzrhBd3awp4fFL9ZsdfkuvMZbd5w8 ODgw== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=8PsDYqTkR2gj0jLcv+GSoOYV3vHkEfB74d3bRiDs45s=; b=JxdpYPjCnza0ORl1cloeJF8ig5p0t4bH5MiEa7XlsIYnFufgI713SeRloMrvP7PsmK 55pMvWAu5HoqQBK15DzqOL6viBaR6fOy8M4na16a7PNHYfTibLsnLrzA1NEN/tUhX0HP dR2FZ3Cqk/8q678RhG32biy3fuyNSPP5Cu88z1uJQryYu1AujgTRtiswmIam7Nrd1Psq unQAuaVyDeF68GDzwiAAAyT6jOHWMSm0g22TLq/pNGg7o2NwnsI5X+eNrZH15K/qZUeY JfIAcJo9LZo546a4LgekGHjbSlzmioLiTejEYXMhbjmB+gUKaFmkphpDHv0kGk/kxC+e rjWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=XbRanRrc; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l192-v6si8114005pge.286.2018.05.31.03.30.51; Thu, 31 May 2018 03:31:06 -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=@ti.com header.s=ti-com-17Q1 header.b=XbRanRrc; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754397AbeEaKa0 (ORCPT + 99 others); Thu, 31 May 2018 06:30:26 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:55819 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754284AbeEaKaY (ORCPT ); Thu, 31 May 2018 06:30:24 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w4VAUDHA030122; Thu, 31 May 2018 05:30:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1527762613; bh=8PsDYqTkR2gj0jLcv+GSoOYV3vHkEfB74d3bRiDs45s=; h=Subject:To:References:CC:From:Date:In-Reply-To; b=XbRanRrc7+iuKoG7b35pCX63d53fDHtJi8yXy2cwJBGoqzedLhp6yd+EtCmI+6olH ln0dAUEcqzm+I+VNoR6GeItv/KffT+FRn2B0nqfgRbfT7HdNM+gdMpBuJfMADQZnoK 8wgjPTPe2xOAWW1aXq8VSGG6yq+/i5Ruc5/C1Qp4= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w4VAUDAb011400; Thu, 31 May 2018 05:30:13 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 31 May 2018 05:30:12 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 31 May 2018 05:30:13 -0500 Received: from [172.24.190.233] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w4VAU8OP022687; Thu, 31 May 2018 05:30:09 -0500 Subject: Re: [PATCH v2 1/7] PCI: endpoint: Add MSI-X interfaces To: Gustavo Pimentel , , , , , , References: <1c07395b28f8b33ce370bd6f15bb1e7f2a95ba45.1526576613.git.gustavo.pimentel@synopsys.com> CC: , , From: Kishon Vijay Abraham I Message-ID: <9787b000-5f7e-a3fa-383d-4d3975fa220b@ti.com> Date: Thu, 31 May 2018 16:00:08 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1c07395b28f8b33ce370bd6f15bb1e7f2a95ba45.1526576613.git.gustavo.pimentel@synopsys.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 17 May 2018 10:39 PM, Gustavo Pimentel wrote: > Add PCI_EPC_IRQ_MSIX type. > > Add MSI-X callbacks signatures to the ops structure. > > Add sysfs interface for set/get MSI-X capability maximum number. > > Change pci_epc_raise_irq() signature, namely the interrupt_num variable type > from u8 to u16 to accommodate 2048 maximum MSI-X interrupts. > > Signed-off-by: Gustavo Pimentel Acked-by: Kishon Vijay Abraham I > --- > Change v1->v2: > - Nothing changed, just to follow the patch set version. > > drivers/pci/endpoint/pci-ep-cfs.c | 24 +++++++++++++++ > drivers/pci/endpoint/pci-epc-core.c | 59 ++++++++++++++++++++++++++++++++++++- > include/linux/pci-epc.h | 13 ++++++-- > include/linux/pci-epf.h | 1 + > 4 files changed, 94 insertions(+), 3 deletions(-) > > 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..a23aa75 100644 > --- a/drivers/pci/endpoint/pci-epc-core.c > +++ b/drivers/pci/endpoint/pci-epc-core.c > @@ -137,7 +137,7 @@ EXPORT_SYMBOL_GPL(pci_epc_start); > * Invoke to raise an MSI or legacy interrupt > */ > int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, > - enum pci_epc_irq_type type, u8 interrupt_num) > + enum pci_epc_irq_type type, u16 interrupt_num) > { > int ret; > unsigned long flags; > @@ -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 + 1; > +} > +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 243eaa5..c73abc2 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); > int (*raise_irq)(struct pci_epc *epc, u8 func_no, > - enum pci_epc_irq_type type, u8 interrupt_num); > + enum pci_epc_irq_type type, u16 interrupt_num); > int (*start)(struct pci_epc *epc); > void (*stop)(struct pci_epc *epc); > struct module *owner; > @@ -144,8 +151,10 @@ void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, > phys_addr_t phys_addr); > int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts); > int pci_epc_get_msi(struct pci_epc *epc, u8 func_no); > +int pci_epc_set_msix(struct pci_epc *epc, u8 func_no, u16 interrupts); > +int pci_epc_get_msix(struct pci_epc *epc, u8 func_no); > int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, > - enum pci_epc_irq_type type, u8 interrupt_num); > + enum pci_epc_irq_type type, u16 interrupt_num); > int pci_epc_start(struct pci_epc *epc); > void pci_epc_stop(struct pci_epc *epc); > struct pci_epc *pci_epc_get(const char *epc_name); > diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h > index f7d6f48..9bb1f31 100644 > --- a/include/linux/pci-epf.h > +++ b/include/linux/pci-epf.h > @@ -119,6 +119,7 @@ struct pci_epf { > struct pci_epf_header *header; > struct pci_epf_bar bar[6]; > u8 msi_interrupts; > + u16 msix_interrupts; > u8 func_no; > > struct pci_epc *epc; >