From patchwork Thu Nov 12 17:53:55 2020 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: 324214 Delivered-To: patch@linaro.org Received: by 2002:a17:906:d156:0:0:0:0 with SMTP id br22csp902415ejb; Thu, 12 Nov 2020 09:54:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlnzjTx8A02SOG7MJO0O83JLaNjESyw5mdD+lcVPXNzyiNJLBx2mpJmrbUXx8vEgio3fJ4 X-Received: by 2002:aa7:cc0e:: with SMTP id q14mr1009432edt.181.1605203692322; Thu, 12 Nov 2020 09:54:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605203692; cv=none; d=google.com; s=arc-20160816; b=z0xgkx1mX4JkJ0ui33t3c54eNBFQcpfnXw/GPPUvmiOE0Qc4LDw4onlrivD3LeYEbw DaoglEz6EPNMO2luKw7XawXH3VfUXSzfWjXxwL+J9BTfNe49x84BoxLjDLUsuxuADTt9 rsbvuQu9nLv1yCHfKAD7YL/bash+9RqZv+Th3fDYVTwrqEnb4C3qB2vhE1H8wCG/03Cy +keyQJWaWn33TDWiK3/KGsKRh8I5Pkv1QscRsne1SO7NsmpBM/l/uMELjnYNaosulwVK Y2xQW0pl+Yob2ce1JbmIMf028r5pOAW9axzyqIJabRWFVPimCVdpRnttaKCwdx5K01ce Nf3Q== 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=L4Bn71NWGlgTCj+F5w02oiIydEpU7yYZTbs/CujdAwxyzkZBUwYfoFCJAzRGu9gwKH XV2JaCTVi7cS2ldzfz2gP2dAFuoRvftks7b4efusxlxueH/sJORQxDjR8/XZ4d6wQRxc NVOA5cu7X6c2MBgXjaBus5G+bm/IYGbJ6mVn0TVgSUOFAIbeStUQxy2VAWL6CwKYUnmL otUzPTErcqyAgxynIUjUjvrGWd2QJDROzxePpIt1u9Nwi2HpxlhSHw3GTbkgre4yDSd7 KQgCnk9kXnyox8PBv8KKYsu8UXHf9aZwCtAUUUlxHKYWBGW2Uaf4L/6XeDEeueWVDtIc wWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=K2gUBEpw; 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 jr8si4389348ejb.304.2020.11.12.09.54.52; Thu, 12 Nov 2020 09:54:52 -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=K2gUBEpw; 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 S1726427AbgKLRyr (ORCPT + 6 others); Thu, 12 Nov 2020 12:54:47 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:59022 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbgKLRyr (ORCPT ); Thu, 12 Nov 2020 12:54:47 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0ACHsOjT028195; Thu, 12 Nov 2020 11:54:24 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1605203664; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=K2gUBEpwuPFGgs2crUGHMQtNsAnZLlHQ2EUHcCZKQ6f1qbeLAKiMGhsRgkQ4akVGb 5P7tCP3ZqLjX3zb3qXgD09232IGm5RGgDpxXZZnJk5UnoPLWkKH15VvXBx9RPVwBQX 8zz5Fr+PS6BENsnFQFnYXzGuqZXJapW9udKSdroQ= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0ACHsO4B006284 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Nov 2020 11:54:24 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) 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.1979.3; Thu, 12 Nov 2020 11:54:24 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 12 Nov 2020 11:54:24 -0600 Received: from a0393678-ssd.dal.design.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 0ACHrx9t094087; Thu, 12 Nov 2020 11:54:19 -0600 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Rob Herring , Kishon Vijay Abraham I , Lorenzo Pieralisi , Arnd Bergmann , Tom Joseph , Jingoo Han , Gustavo Pimentel , Marek Vasut , Yoshihiro Shimoda , Shawn Lin , Heiko Stuebner CC: Greg Kroah-Hartman , , , , , , Subject: [PATCH v2 3/6] PCI: endpoint: Add support to link a physical function to a virtual function Date: Thu, 12 Nov 2020 23:23:55 +0530 Message-ID: <20201112175358.2653-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201112175358.2653-1-kishon@ti.com> References: <20201112175358.2653-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, };