Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp383606pxf; Wed, 10 Mar 2021 08:12:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvcFgaWYVxOCbYwZlbcjyZOmNTyWOzKrFJyKwf/fsg3ih29xzTQlRh80nZiZSmIlU4E4j2 X-Received: by 2002:a17:907:2bf6:: with SMTP id gv54mr4574514ejc.514.1615392759195; Wed, 10 Mar 2021 08:12:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615392759; cv=none; d=google.com; s=arc-20160816; b=eQjh4EvQv+W2CD7oyjGuDHCLQEPymJlEHqX9TxL4V+9Ua7x2tHnD78Sygh+vxf94oT E/ljXxgHjFMBOOH5dblFi72TbveX5Sv73YwNhYv7dDw1ByH2xKDHh02EdESyHym55R80 B9r2iRCSKPeyKElnnBbrGSjvXg3qFh7VKNGxfzmQIejhN6ArerTg4LSWkGhTYwQCkd3l M/4S7cxccx+GQFQP7o/u7BMGpVJRxRXL2+CObEtW57zBXbIjfDB9PROJj333fqNlZgUE pXYOG7XsQHcopYfCoOFhtLtDBwm9EYevPbA9vH+PCA4yfiG79OAkptFlEvQUldK1Q6Xc jZEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; b=gFjfY+n9sOFGezZM1qYQ63iVeb/avtwqo9ZY9sLy65u3mKM2HSOLRCycIpWqRPpJ5Y aYHN/hMI35Ec+GYytxhnAt5II7rz8Qo2oainqViEfDyP/8BDzU1mpEWrV3Xu6d08b+hX A1Hv8pAA/RI77AFDeVyq/B+Xn2FTAu7QqPqADUNyKtltzXKd2TBhOVV10u3GQNbsELje GbyY73vPfzIRd5gsTgf22uABJVx4h4cL7Ra1iWxXF6lzfV4pdm2fnRuZX9AhlFOQuNQX /7L8II0uv4rF+2M8eGNR41Ez2aq24fjCtOugyOYF10jpIjEksm00PCTV9zLiNCgNK1qY L6uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cKQQte9h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id c9si11893595ejb.466.2021.03.10.08.12.11; Wed, 10 Mar 2021 08:12:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cKQQte9h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233354AbhCJQLG (ORCPT + 99 others); Wed, 10 Mar 2021 11:11:06 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:51500 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233250AbhCJQKn (ORCPT ); Wed, 10 Mar 2021 11:10:43 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12AGAKgT127932; Wed, 10 Mar 2021 10:10:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1615392620; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cKQQte9h66p0BZQg0GzYo+D4kirMxlbVKoLIhPhty5upa+/3tO4pGrEBrm4IQCfk2 UipUvBysP/8TYHIlsXHjQqAim4vnEa1GTmiCKcDaIv8zzaCm1li4LLNUfNicVDJ5Oj XbPrFZ81D8DJoWVgYs5dMh+9ZRvfcUm6twKgXZgk= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12AGAJWg093655 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Mar 2021 10:10:20 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 10 Mar 2021 10:10:19 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Wed, 10 Mar 2021 10:10:19 -0600 Received: from a0393678-ssd.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12AG9qku100440; Wed, 10 Mar 2021 10:10:13 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas , Jonathan Corbet , Rob Herring , Arnd Bergmann , Tom Joseph , Jingoo Han , Gustavo Pimentel , Marek Vasut , Yoshihiro Shimoda , Shawn Lin , Heiko Stuebner , Nadeem Athani CC: Greg Kroah-Hartman , , , , , , , , Lokesh Vutla Subject: [PATCH v4 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Wed, 10 Mar 2021 21:39:39 +0530 Message-ID: <20210310160943.7606-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310160943.7606-1-kishon@ti.com> References: <20210310160943.7606-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the physical function has to be linked to endpoint controller, the virtual function has to be linked to a physical function. Add support to link a physical function to a virtual function in pci-ep-cfs. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-ep-cfs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index f3a8b833b479..999911801877 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -475,6 +475,28 @@ static struct configfs_attribute *pci_epf_attrs[] = { NULL, }; +static int pci_epf_vepf_link(struct config_item *epf_pf_item, + struct config_item *epf_vf_item) +{ + struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item); + struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item); + struct pci_epf *epf_pf = epf_pf_group->epf; + struct pci_epf *epf_vf = epf_vf_group->epf; + + return pci_epf_add_vepf(epf_pf, epf_vf); +} + +static void pci_epf_vepf_unlink(struct config_item *epf_pf_item, + struct config_item *epf_vf_item) +{ + struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item); + struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item); + struct pci_epf *epf_pf = epf_pf_group->epf; + struct pci_epf *epf_vf = epf_vf_group->epf; + + pci_epf_remove_vepf(epf_pf, epf_vf); +} + static void pci_epf_release(struct config_item *item) { struct pci_epf_group *epf_group = to_pci_epf_group(item); @@ -487,6 +509,8 @@ static void pci_epf_release(struct config_item *item) } static struct configfs_item_operations pci_epf_ops = { + .allow_link = pci_epf_vepf_link, + .drop_link = pci_epf_vepf_unlink, .release = pci_epf_release, }; -- 2.17.1