Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2319829pxb; Mon, 19 Apr 2021 02:55:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeJ3YXRX6Jz66iQFNbWyTLcmBoxhKQ1yF7Lx0oGdoEg8meimlutFssBlPppWxJJ2+MCMFv X-Received: by 2002:a17:90b:1193:: with SMTP id gk19mr24084245pjb.143.1618826142777; Mon, 19 Apr 2021 02:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618826142; cv=none; d=google.com; s=arc-20160816; b=MB7yB2ufgKxWC2fdsnUsvYYzuM7HWEWpxbNHCMeESA+awTzi0SwRE75c9shjwcCH49 lWgfL/pOy9Pj2WkQk/BeFu893AkS1d4vVnOG0lZqMlslre7aJxs5HSxoz1YjmnSwyA4J TMKwXT+3DMUZrESBmdhjl6j/PSx8kJvJgGc4siS9V+3wwLfXv7NdWwoiea5XPIxu/cAS A7GUy56ypnlEuxo1TccDLc48Lhe3Z23DMCedka9jxxWOZoGghNNsoEPr+P047qwzAnEI sxPv+dAno0Ek6QRJCT6F7EKk3gF2N3UozkjhvqwJrQ3dBTSzZads8GttuatFORU2R1dI BupA== 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=ot04gxy9TThaTm0X6AE9WTc8iTTNHIo3xkII/nTJVEGGyIIg1WT46qKqBq7e0apU9L awFQ1sqgt2QrtlJjz4x0ksvoVBAGi96V/tNRDlqY1fBCXq+9w/x9mlWsnXfFFYunY7aw SX85Epr7y1gOjl/ebIGC3jusCrBNfWiH4cSjCNVaVDHHuPGUer+rki6nK4ahzKwUAFud vBDw35wCa/lZcO6/U/yNe4PhDRtx7aMreOOEi7nS8sLbJUWk8jrEtMf5JlZMjqgCEyVS ZplL4kf6V9hIs6F1vXJrR4u0IsjBCJpH6m0hTKeg64bPx+nfDgRSqzviBwDEzaTN8bbt o81A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="KIA/Xg2W"; 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 x17si16399749pgi.122.2021.04.19.02.55.29; Mon, 19 Apr 2021 02:55:42 -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="KIA/Xg2W"; 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 S238197AbhDSIfX (ORCPT + 99 others); Mon, 19 Apr 2021 04:35:23 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:38094 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238169AbhDSIfW (ORCPT ); Mon, 19 Apr 2021 04:35: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 13J8YXui119265; Mon, 19 Apr 2021 03:34:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1618821273; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=KIA/Xg2WmJnjxvzl2hud17raWJBObxC0XlaXsYEtYDwgehkZTOa2Ic/Ak1KLFgH6i V+1/hjN4bsAmXAw+sSknsek8ttPDUm9yehjLxUuWENgKcfp7ZwT7FvH2WQOP6tq2BD xJW0Yhm7PA0AIzhJyNnyKZ+iH2I3QWwMNwWPH5zk= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 13J8YXE9025413 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 Apr 2021 03:34:33 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 19 Apr 2021 03:34:33 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE104.ent.ti.com (10.64.6.25) 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, 19 Apr 2021 03:34:33 -0500 Received: from a0393678-ssd.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 13J8Y2aS051194; Mon, 19 Apr 2021 03:34:26 -0500 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , 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 v5 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Mon, 19 Apr 2021 14:03:57 +0530 Message-ID: <20210419083401.31628-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210419083401.31628-1-kishon@ti.com> References: <20210419083401.31628-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