From patchwork Wed Mar 10 16:09:39 2021 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: 396759 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp502783jai; Wed, 10 Mar 2021 08:11:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYFjkUbjdePtsOu0EbfmkTZhGWtgturChMXEDRykV3dRIVKsdWiamy+nOTiCdfBUPmVpzx X-Received: by 2002:a17:907:3d01:: with SMTP id gm1mr4539088ejc.214.1615392698408; Wed, 10 Mar 2021 08:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615392698; cv=none; d=google.com; s=arc-20160816; b=mh/LIw2uZmFPl5t7HBaw9JBhztG7e7wPNjZdHAJ6l4UVFSOmJLooK58+ojPcjOOYnJ 44CJuPifAqw9alPvs0fmt78+TEd8yUZHLkDKvKVaq+Q3SF9cppRbktmCrNpS7/AfvwR5 Zvto3uB3N6BmYnE63LCgNjJ79xE5PaCb/xpHr+tW+sk5r6/pH1jcZIea5NLC39czAggC dnjEmcI+xUFBNtgZC8tqgEdeu5jGtSly4GQJtckPX3FYmkRMg2YrlyvKYwjagTpMFiP0 uY5GclLroDYQFwqFE5LwKfRiqynWcvFhF//zfxutrODunHIfgaIhF//8Jru8lcPI0dQX ulFA== 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=E0dwKfsWHKUlHINvivPzhTmeY79Sm3+PTrappp9pSnb4MBLzWA3FhzkZ5TlDwJKUky 0qvuxFYxXAgoM+3hdk9I/gc4+G7xNnfkmgi8pB348zW07dv6ec7p0Kl7T/9FQBnCtzxq AtID8d7tPzZY0LXRog/xyxsOISjU9szMZrfl5Vz+VXGmgW7mZoIw1a7k2PxH1ryUChMM U/r8Ts+mqKnf7zQlnHkfaWMyIUTJZoP8zWndQyzXcFlJhKvxdh+7rn1UU6Ob+9QwbAPw t+WsEUWDlFUZAXDbYLd9uKMoSROCzLgGjlxEYYJG6YIG3cfB4fEMFipM8UIgqa0Cfbls mzDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=cKQQte9h; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id rn25si8164962ejb.250.2021.03.10.08.11.38; Wed, 10 Mar 2021 08:11:38 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-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=cKQQte9h; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 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 S233273AbhCJQLB (ORCPT + 6 others); Wed, 10 Mar 2021 11:11:01 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:51500 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233250AbhCJQKn (ORCPT ); Wed, 10 Mar 2021 11:10:43 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12AGAKgT127932; Wed, 10 Mar 2021 10:10:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1615392620; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=cKQQte9h66p0BZQg0GzYo+D4kirMxlbVKoLIhPhty5upa+/3tO4pGrEBrm4IQCfk2 UipUvBysP/8TYHIlsXHjQqAim4vnEa1GTmiCKcDaIv8zzaCm1li4LLNUfNicVDJ5Oj XbPrFZ81D8DJoWVgYs5dMh+9ZRvfcUm6twKgXZgk= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12AGAJWg093655 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Mar 2021 10:10:20 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 10 Mar 2021 10:10:19 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE110.ent.ti.com (10.64.6.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; Wed, 10 Mar 2021 10:10:19 -0600 Received: from a0393678-ssd.dhcp.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 12AG9qku100440; Wed, 10 Mar 2021 10:10:13 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas , Jonathan Corbet , Rob Herring , Arnd Bergmann , Tom Joseph , Jingoo Han , Gustavo Pimentel , Marek Vasut , Yoshihiro Shimoda , Shawn Lin , Heiko Stuebner , Nadeem Athani CC: Greg Kroah-Hartman , , , , , , , , Lokesh Vutla Subject: [PATCH v4 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Wed, 10 Mar 2021 21:39:39 +0530 Message-ID: <20210310160943.7606-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310160943.7606-1-kishon@ti.com> References: <20210310160943.7606-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 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, };