Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp533001pxb; Thu, 19 Aug 2021 05:36:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTILjaLb2PfLPDNxHE5/6B6+c6N9s9zvv3+Q8XcwpxwOBpUy/qgSHey2gNte8rEm92CiXY X-Received: by 2002:a05:6402:2794:: with SMTP id b20mr16709993ede.126.1629376609069; Thu, 19 Aug 2021 05:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629376609; cv=none; d=google.com; s=arc-20160816; b=QbyQQoiuy7w+FfHdchLUjOyJ6TMcYMQXYWiabEss5oRAAA0Ow+hdIyMuGRpzmQ1wlD dwI+S9O4Sw56dHwd+FwrKrFx76VE2DX7Mkf7SgesKIYLimngpMmyzRsdfKbR2uv8L18Q XOJj9KwDsmmdnn1o0SuZUzamc2qUMZxtwfVHdIIzNGddvJKDd1p+aKJ6fjp++rwo/sZt ttaCE71e427wZy+QmBe7vLBpU7hzxzeG9Qi+ffQ/K2uQaw1VnpfvYu6d/juP9fCu2vFL boMvdsV0bgJoRMpcwq2eRXDSSx9p6DCwBR6ixZzIWvGJMTZ+Z45pAQEgMHWpKLg7ZRJZ HEGQ== 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=Na85xjK/447PLoYxmRytJFT7/TjNjBYt0eJm8hrzJoOlZaZiAmwxW/0ix9ujoWHbk1 BOIrGRgMLkI7tAVVjh1TW7rao/+/8BwtrQ84FPqJT7siAWicwlRty9vJ3rT8lMDvLjP3 isnMfzFcG8RAhOdO3UVUdThXYbesGeBZORfVa0kvDwrVnrxE6am7r+I+PM+JZQHE8y4U 28z8mLwSIPpDx+Qh1p++Tr9dK+wt7LgXFwAejU3Zk/dnfTMz5k/MTBA8QZN/izByFWlG RdW4kIvsobAtq6NGlCNK7yOE0IdPjbiUjOEzuzr7d+WZeOc1UBjln0f11hzrvMn0iv6U j4TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=qK90ihm8; 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 4si3112789ejm.546.2021.08.19.05.36.25; Thu, 19 Aug 2021 05:36:49 -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=qK90ihm8; 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 S239535AbhHSMfT (ORCPT + 99 others); Thu, 19 Aug 2021 08:35:19 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:41046 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239472AbhHSMfR (ORCPT ); Thu, 19 Aug 2021 08:35:17 -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 17JCYFNd105161; Thu, 19 Aug 2021 07:34:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1629376455; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qK90ihm8ZTCDiy0YeI36BRVPEhCgyELzISZQxQjKUvFNdOI1iNOXzCsj45YSYRjLH qiexPgDwrPDeZRiKpogI2i29fjS+57nBOdx5/hw5EqZRRgU5X2InXqnAaHmQhFX9l8 3N987oppTUnVCRVvSXkXVmgdHhlc8f0rVp1nRou8= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17JCYF9b107283 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Aug 2021 07:34:15 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 19 Aug 2021 07:34:14 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE111.ent.ti.com (157.170.170.22) 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; Thu, 19 Aug 2021 07:34:14 -0500 Received: from a0393678-ssd.dal.design.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 17JCXlZR035715; Thu, 19 Aug 2021 07:34:08 -0500 From: Kishon Vijay Abraham I To: Lorenzo Pieralisi , Bjorn Helgaas , Jonathan Corbet , Rob Herring , Arnd Bergmann CC: Greg Kroah-Hartman , Tom Joseph , Jingoo Han , Gustavo Pimentel , Marek Vasut , Yoshihiro Shimoda , Shawn Lin , Heiko Stuebner , , , , , , , , Kishon Vijay Abraham I Subject: [PATCH v9 3/8] PCI: endpoint: Add support to link a physical function to a virtual function Date: Thu, 19 Aug 2021 18:03:38 +0530 Message-ID: <20210819123343.1951-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210819123343.1951-1-kishon@ti.com> References: <20210819123343.1951-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