Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1743854pxb; Thu, 4 Mar 2021 21:07:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnLGp0UkMZiJzuOZdSRE0RQYTa44R+zWQGH3ONMPpVCnCY8laFooppuQoGohZ/psVdlT1q X-Received: by 2002:a02:272d:: with SMTP id g45mr8088913jaa.117.1614920822212; Thu, 04 Mar 2021 21:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614920822; cv=none; d=google.com; s=arc-20160816; b=zswTohHp/RdqssQj1kZrekeLq8yrfq7L+c7ZtKok/SaEc25gmlsbTZ4qwvlNa3rnye LZOSvH05mCmW7epOTQAN3of574teQbnl+qQ41uYzijvWIZ40cZjR6rydvdaOkbXRyT1r aKIKBcOMW6/B7DRjEl6UIbraB8PAkGEhM2iEdgV9e35Sq0g8KtscVCm0qci2gMcmT6tL hWzGxrAJ3MLFbryy1hXzdGpSNCEAGMHZIh3yhxhEEGxQaTRvwzTS5oZYbDlJAyoAYLqj 47pMnEywV4HT2TPoUE2IY5oITOpERoizAxyVi77gkdRyzUZUPIfYsKX3Yk7YM0h0k9fQ Y91g== 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=DvaxbhumF39a8UihB3JlPfNphXTyGlM2rihbOH0y3yJ6LHhpTMDZMxaMDYk0hK6u2S R1ooXOaTxI9gZVmY71AK7aCD/fuJSCdZz0QgHz4ros4/F2uCwYiVUy/Nz8oF8UOw0rhf p1PoGIPaftkZifAuJcmCjee0q0/Eb5R6lmKQeQhkem7+rQAw3HXYe7ru56srB8jy0Q2R Q9TI6k7qTk3b22T7bxLEFDfDhtMTmaPo8e6Bh1zsdYLZSqR66YZ+vHA4GlrGYmGXpIro QW9CDwHvYhhgxhq5+XYw6g7YYNIAsWiUtosQRR7aQCNsAr+H+qcq4Dibg2KSM0aJw8J5 i99w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Aw77jxUa; 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 e21si1442519jaq.58.2021.03.04.21.06.49; Thu, 04 Mar 2021 21:07:02 -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=Aw77jxUa; 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 S229601AbhCEFFI (ORCPT + 99 others); Fri, 5 Mar 2021 00:05:08 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:48950 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbhCEFFH (ORCPT ); Fri, 5 Mar 2021 00:05:07 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12554kTU074947; Thu, 4 Mar 2021 23:04:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1614920686; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Aw77jxUakLN17FvgAG/jkmtIzJsR6ywXTsNadGsqlTyMGsF7wy6feVFZMY6P5aYIf Mhz7hu+w/KW8q0o/TSvQo3tdJycMycxCvu1Bsd4BmIlZ/f4Hm/kSaMFSt8VvK30ygt ETrambS5DvvmkMaf/amZexXLE3RQC7Y/dyOKa4Nc= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12554k6Y128105 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Mar 2021 23:04:46 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 4 Mar 2021 23:04:45 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 4 Mar 2021 23:04:45 -0600 Received: from a0393678-ssd.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12554D98116197; Thu, 4 Mar 2021 23:04:38 -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 v3 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Fri, 5 Mar 2021 10:34:06 +0530 Message-ID: <20210305050410.9201-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210305050410.9201-1-kishon@ti.com> References: <20210305050410.9201-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