Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2427612pxj; Mon, 17 May 2021 01:00:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAH39h9KFFBsialVULbzSvf46vnxmVNF9aAchHCaLd9nLA6UxMCgJHyoCvHBsqfD9ks73X X-Received: by 2002:a17:906:1699:: with SMTP id s25mr9648477ejd.238.1621238435342; Mon, 17 May 2021 01:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621238435; cv=none; d=google.com; s=arc-20160816; b=RtBR5GVybqopquf5pAFFMA+4nyatL4mOGtp0VPtiSxqewql91AJZAusy+kFdQ5Y3SS Qd1zH2wD+JPVzWXIsFIvK2iodmuzmdgUJ7Kayzrde38xQplKxW9oc4x2hmoxW/UgRlGV pEjw3nNoTjHGii5XvITP0lZq+huRWlAq72oF2GNzoQ6XRC80oBn7FQbX6UiLk+wrFgEd QDxBhN9sEY8geJ1llZdV8u5DMbasxV8eU/cH5EbUtVbfhpxIEjoC+4bTW3XSFLLy0N2l OR3AoXJnSHm0Wz3bqZp3xV9VqPYwkPrYHXSTyUA1SbwtKmXgp1yv+JyPetCAAC23QwRq gdag== 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=lMQgnEL1t7aTwAeMkrvOeJvkpoE3Ieqq/J/4EcmkV6p8cgtfa2kwVcRBXSawLjrFps Z2wXdIOaWb8kMG96GGFAgtYgjUjrhSo189tRhBBsOJipUjhU4ROPTD67VOSQI5gRgpe/ 1M++DOD7ByTFqIE1c3Hz7qu7pK57ykcPv/i35lEGpO8WYAP3tjhSHd2Il8OrxPg63APy 87lx4VRE/1O++c/M2iLlATbuA2rwrn7FirnX1w+2lTSgqeuhebH9wgh85GbRVCkk/FN7 PnZWgbfIJroyl24I+pqwkbYeWWKheRUV0/deC4SsviUCTi5ccLRl55GCcOj3bEIL5hkJ jKyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bGM+nBVO; 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 bx19si13567035ejb.481.2021.05.17.01.00.12; Mon, 17 May 2021 01:00:35 -0700 (PDT) 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=bGM+nBVO; 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 S235492AbhEQHtw (ORCPT + 99 others); Mon, 17 May 2021 03:49:52 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:46738 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235471AbhEQHtf (ORCPT ); Mon, 17 May 2021 03:49:35 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 14H7m0jE074178; Mon, 17 May 2021 02:48:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1621237681; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bGM+nBVOtvfTwFXA+ndJBErcdYQ7FjYyjmWLXYBuFYaTOrWaxR141taiXcjMNZKGo bJsw9m8dwVQL9RnlMvrMZksTY+KD7Etq2Pr1rXLX+n/xo42Y3pPq1xh3YSfSbbdah4 UVw6K/RbN9JBN9WsZC1bIg2BkPl8ZL0kODvHFXGE= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 14H7m0ag049709 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 17 May 2021 02:48:00 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 17 May 2021 02:48:00 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE101.ent.ti.com (157.170.170.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; Mon, 17 May 2021 02:48:00 -0500 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 14H7lOcg007607; Mon, 17 May 2021 02:47:52 -0500 From: Kishon Vijay Abraham I To: Lorenzo Pieralisi , Bjorn Helgaas , Rob Herring , Tom Joseph , Jingoo Han , Gustavo Pimentel , Marek Vasut , Yoshihiro Shimoda , Shawn Lin , Heiko Stuebner CC: Jonathan Corbet , Arnd Bergmann , Greg Kroah-Hartman , , , , , , , , Kishon Vijay Abraham I , Lokesh Vutla Subject: [PATCH v6 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Mon, 17 May 2021 13:17:19 +0530 Message-ID: <20210517074723.10212-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210517074723.10212-1-kishon@ti.com> References: <20210517074723.10212-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