From patchwork Fri Mar 5 05:04:06 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: 393465 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp119842jai; Thu, 4 Mar 2021 21:05:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcxDjjC1ZXaGsPBMTPRo9M7oGMfH0+SKl9tCd0E98qn4NgalnHJqtyhbHUnZASmE/W3mdA X-Received: by 2002:a92:da91:: with SMTP id u17mr6913908iln.27.1614920708683; Thu, 04 Mar 2021 21:05:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614920708; cv=none; d=google.com; s=arc-20160816; b=aW3tIjwwOUxFktqGm+Fv9Cyu9m6fG6WLSL3ozgjacALLftdJah+yuCP55SKo4IgIgL J8uihv+96whP08G0ZvQDDj5HljSbXsDz0EfWXV8WVdNGjbrfv0NjfTpy4xlV60uX1uvb R4oMaxDhJsIo1mis7Ch2s/MGzbhuNJZKdeZe350EPN6MuiBO3nd6WZmyfV8+aJGLbf8c idjUWfsWdCers9+d9MzZa9mGdnX9xCNjWzEBdTyT1ycLBeX6UN34UQh5xX7MQftz3WfL uo4Ygx/QNyz7s0iCqA907oRRvhjGW2lyUFwf9xztWOepFXSgq3GzOZJTJZzehcMW2r27 iTjg== 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=vL5Ymh+2xsZBdRx1Kfr8Eugov/Jx+9gD7RwSB7FIA0NgTJhxWxq+Ezstg9CrDfVb32 KwT/JiWaY9v86OP8Yx3V+JQ38d77kFu8r8pAGImncEtZOm1dwBSwUG69R9eN2gwuTW0h fQNdYuOOD8BwtwkB6HE3W5idcK0E6R9y8ShiXoWvLbcSAhnyYmgP35Pl4Qc00aKiFtfU tnovT6bE4tBLVHASAL2AUzVu6iMoJ2kGDRVvM2ugebLpeJvL+SGuAml4FBWCjYxCLOi3 QDtoKYLzSfE894RACM9ur6nHJqF//pBVrtUbkSawxcKiISZ5k627tZt+fHoZWJARCpYv +bAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Aw77jxUa; 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 i16si1431431ioi.40.2021.03.04.21.05.08; Thu, 04 Mar 2021 21:05:08 -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=Aw77jxUa; 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 S229608AbhCEFFH (ORCPT + 6 others); Fri, 5 Mar 2021 00:05:07 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:48950 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbhCEFFH (ORCPT ); Fri, 5 Mar 2021 00:05:07 -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 12554kTU074947; Thu, 4 Mar 2021 23:04:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1614920686; bh=xZP94/W6e+feo2IXbD5QHf0IlP942uGU++0kfiWPUQA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Aw77jxUakLN17FvgAG/jkmtIzJsR6ywXTsNadGsqlTyMGsF7wy6feVFZMY6P5aYIf Mhz7hu+w/KW8q0o/TSvQo3tdJycMycxCvu1Bsd4BmIlZ/f4Hm/kSaMFSt8VvK30ygt ETrambS5DvvmkMaf/amZexXLE3RQC7Y/dyOKa4Nc= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12554k6Y128105 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Mar 2021 23:04:46 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 4 Mar 2021 23:04:45 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE105.ent.ti.com (10.64.6.26) 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, 4 Mar 2021 23:04:45 -0600 Received: from a0393678-ssd.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12554D98116197; Thu, 4 Mar 2021 23:04:38 -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 v3 3/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Fri, 5 Mar 2021 10:34:06 +0530 Message-ID: <20210305050410.9201-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210305050410.9201-1-kishon@ti.com> References: <20210305050410.9201-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, };