Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2160347pxy; Mon, 2 Aug 2021 22:05:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzm0eGjd0PjI3RcNG8dzrYHyx4Jmi6i0C6QLKy9Ds8H4SLFpm0NXc4w1p1kmkOVSCPVQKqh X-Received: by 2002:a6b:5d14:: with SMTP id r20mr446314iob.140.1627967147850; Mon, 02 Aug 2021 22:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627967147; cv=none; d=google.com; s=arc-20160816; b=XVxsQVftJWx53AvEC7Nf674astHaxLiV84oRI+Fr/2A0iizq+y2OCDlvlCssYSsXqn Q7vNVizVAF9HW2S4TMWGmwgrCAoNXGrHnTZXnfC7dUK9uO0V3NNnUAbTNBXN4QEsSeDz 8OzesInYManrXAxU8zH9vBYz99N0/LwF3UP4oxWQMJfeDl1JFFcix+Erk3fA6jNZ09RV 9NH2qOETltFpJ2hSVvAB272m3ycHCW/7APz72w5aVwUlBWgmPna2cSDUcX5JgsPuFK5Z na2Y3u5wgNIp5BdvqgUV7gL2iSyZtUjvpTKS5CnXxVGsauSXlIML0BBlaruKNOBUuSA9 48gQ== 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=bKl/3sRs1pxKZD9sjjHC/aKVkuPuhT7pvdR+cw8iX+h416yLlIm9NiMcfq9inudy3y WFab7KdsZtD8ESDFWImwKqXQE790sY/ZXVtT9GkwpbbIIPcIcA7xHxfTm+8q8VQJ0sCT hBSw8PvCypEk9iGKmLMqpxLGo8Ka4xoXUUXlauBFlwQBQsS4f9wOC0n66eqJceAyLBF6 O4IO8i/NnwxFj8LUn0kWGXUUyUPP7SEsgQFVzMsVDhgC5LshzuKdupnapTuc0TimiU/9 2pljAlYj7laVSnPycKXCd13kZ+nuuTj0xQo5gXDqyShp6T8yCnLkiu+/9hl2rNnzBw5d bXOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=R5bCYBeL; 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 r3si14826198jan.7.2021.08.02.22.05.31; Mon, 02 Aug 2021 22:05:47 -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=R5bCYBeL; 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 S233811AbhHCFEX (ORCPT + 99 others); Tue, 3 Aug 2021 01:04:23 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:51678 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233839AbhHCFEW (ORCPT ); Tue, 3 Aug 2021 01:04:22 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17353reM093786; Tue, 3 Aug 2021 00:03:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1627967033; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=R5bCYBeLPEkAOY+Rl1Y2uAxOIs28EXnC2enDueQQI+im3Hx1XUJUpY5x2pjI5xq9h lWnYeNNjHQIcAiFfbGngaoKVwxyBvHPc/PntYSEVednE6sUFfpWc3cMs1zP7m4A8zH scrZr6V5hCbGIaCKThKo0XTqRDITXfFcgYsrDoAg= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17353rqC098723 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Aug 2021 00:03:53 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 3 Aug 2021 00:03:52 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) 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; Tue, 3 Aug 2021 00:03:52 -0500 Received: from a0393678-ssd.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17353BeT090231; Tue, 3 Aug 2021 00:03:42 -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 , , , , , , , , , Lokesh Vutla Subject: [PATCH v7 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Tue, 3 Aug 2021 10:33:06 +0530 Message-ID: <20210803050310.27122-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210803050310.27122-1-kishon@ti.com> References: <20210803050310.27122-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