From patchwork Tue Jun 4 13:15:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 165784 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5844481ili; Tue, 4 Jun 2019 06:19:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxAHFoI4vYCws32xEXDod0uqdRBQwVkWoxFoTuJXqJCCwjkVwiIL6o7hOnFqkXP8oSQn0q X-Received: by 2002:a63:ff0c:: with SMTP id k12mr35511442pgi.32.1559654352537; Tue, 04 Jun 2019 06:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559654352; cv=none; d=google.com; s=arc-20160816; b=eE082uH+4oOt422HE3Iauv6NkRxlOlrx5UeUIlE6/yYsmH3RIQsTsn6wTxQUIXPcUR zsdK8WoXTaUT4pklUj26Eo4Qzg3oVM7VVdsgd2ICBhDucYIs4PsuWnK217BhnGk4Gu4+ 9UgNp/DbnDfnbSxHQR5IQ2mPihjE6E/CjIEoQGigit2fKZ7cYM6UBmNaFDsVCWOr0zXj F7Y7Wh60FQbuPNszXX65poevrYHwcTqVHpgD076JNmIwZRxUKOo5Hw0kXn3d3qHnraIi I8/B7IwyajF0oNwDM3Cg3FjyX0EsbFGDIURBUVn+RBkAsgnicDEDCKdSfTfHt3FXgCz9 g9qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=jqsa++lCvjyELh9SjLjw9ykSFWnOzndvoFRmjfRfvbM=; b=HPV5NpMFW9LWuQRbrnpG64KeNm0mrEAG/plGgUCgcIlARPAyzNGAqN4xQzApN8qhrf Bf2M68XOP+Qzf35RDI3MSZ4Woiygj3iV8IUccC46Fhn9MMGZDHjLckm90+E4o7bH9QTn 61qqJu9EalCtmfkG3UMyFP0wKKSwDRYz/MFDV9iT8zdpS8ZeeCOndp/PcUYV0z4am4Ht RRpLhJfM9oEJQ2ctmX5j/8soUrcSrdCTkxvcU/xJF5vTrYH5O/hcJulTsrO/7gTYh0pS P8DlrF80g4YCl4Xc19JS3iTSMbL3iK6Q42qrIrdc+RZklZ+IuVz5Ki6+Ju3P7hTa6y5o z/zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SJafN6MA; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 f4si19841722pgo.216.2019.06.04.06.19.12; Tue, 04 Jun 2019 06:19:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=SJafN6MA; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1727902AbfFDNTL (ORCPT + 8 others); Tue, 4 Jun 2019 09:19:11 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:50568 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727893AbfFDNTL (ORCPT ); Tue, 4 Jun 2019 09:19:11 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x54DIVce082525; Tue, 4 Jun 2019 08:18:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1559654311; bh=jqsa++lCvjyELh9SjLjw9ykSFWnOzndvoFRmjfRfvbM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SJafN6MA92yKSz6dnMDxTTSbwugOvtBPxvXPk6dN9oGWrdM+bxvO9y+d+3fSZ2020 FjR8jknaD/OjckdHuenkfWAtz88nO3FnwFjWOjMOihJoROvPIjviRSeSN0KnSuHLPz /HYf2IOtakaVtsthLtvLltjaUW2Td3cPbKsUqTe8= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x54DIVRw009609 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 4 Jun 2019 08:18:31 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 4 Jun 2019 08:18:30 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 4 Jun 2019 08:18:30 -0500 Received: from a0393678ub.india.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 x54DGdGZ098972; Tue, 4 Jun 2019 08:18:25 -0500 From: Kishon Vijay Abraham I To: Tom Joseph , Bjorn Helgaas , Rob Herring , Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Gustavo Pimentel CC: Greg Kroah-Hartman , Frank Rowand , Jingoo Han , , , , , , , Kishon Vijay Abraham I Subject: [RFC PATCH 19/30] PCI: endpoint: Add support to link a physical function to a virtual function Date: Tue, 4 Jun 2019 18:45:05 +0530 Message-ID: <20190604131516.13596-20-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604131516.13596-1-kishon@ti.com> References: <20190604131516.13596-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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(+) -- 2.17.1 diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index e7e8367eead1..c18ef626ada5 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -350,6 +350,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); @@ -362,6 +384,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, };