From patchwork Tue Dec 31 11:35:31 2019 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: 182676 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp7471274ild; Tue, 31 Dec 2019 03:34:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzayBWdTKhO2EQfYWtRXy5zY5eCGi5a4o9X/hv2aOKC+uwwJNI8LllvtPLah9ned9klrocL X-Received: by 2002:a9d:12f1:: with SMTP id g104mr82395175otg.334.1577792067376; Tue, 31 Dec 2019 03:34:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577792067; cv=none; d=google.com; s=arc-20160816; b=ROx8FfEHTVOPZTdCv/vEXROkhjw2G/HX3Gx7jWiwUeZ63pTpxRgbW9qzfQdPziVno6 Iv5NjktuXKDe/7RGJjEPM+y4Vc9jDPnex3xjenC2+cBb8PqzNSnrJd6VUzEGoACnktIl WZlY2ZPOSfEtsz8nWh3kwluqAcuENCIW7W0r2J4II6leO8/9ANYoqVbsWO7WNH6BLGtp XPi1e0e41bL9y+ptAQ5FyYK0izRlFojYsSZna0wSE1lsz2MDmhkdxDS37AdqqfXinZLL EW6YczcCni7a1ju3RJWsxceud/rhcFlYpjB1Dg8uIOzS4x8tggkqCVRy8N3IBSO1simi NoXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=jqsa++lCvjyELh9SjLjw9ykSFWnOzndvoFRmjfRfvbM=; b=RgdvJ53Qae60ZjADJH+ATxmxH7naweqFV236LJMFjwVYen+NtALM7osECdvbNspdzh v8Mbh79JqEisskBO3I9Ejict97huMiCQQYauhwemwHML4nnbJg/QF2q+wCscS7snbtDk QA6a1e0tsb3d2RBjwgvu/5ZZ0pXzTkXHOcO2a5MuvHo4qFfNmwPnTGgBtkWgBRvTSddn wmzJmQGv3f6fc8DrLmWoHGl5SEmcZiIO9sYz0uzcITsnDHWUi9k3RNuV7ef6nBfzM46w c5mU0eURxLHYcZUNO3TnPuOoywdDp0yHbW/11ed6+Gf8wgCIZrJVsUzpxjj5sloGzHsY q+vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eYa84y0l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v21si25124920otj.282.2019.12.31.03.34.27; Tue, 31 Dec 2019 03:34:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eYa84y0l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727189AbfLaLe0 (ORCPT + 27 others); Tue, 31 Dec 2019 06:34:26 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:33442 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727145AbfLaLeY (ORCPT ); Tue, 31 Dec 2019 06:34:24 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBVBY0cx121219; Tue, 31 Dec 2019 05:34:01 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1577792041; bh=jqsa++lCvjyELh9SjLjw9ykSFWnOzndvoFRmjfRfvbM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eYa84y0lK9EfPbFapBY8/3Zn/A3ew9pjim0tgw4m7cTU0eIFjgSdm8Ze1JeZ/oAbA JOpZtRaXas6AYgBNik3O4EQ5920P7vBptrM6GB2IuAZnThb+e6oPvhuZhjk93Ckt9u LcSsPpfar0v/aGEpD3RwU7/5EgKBM25/h88hpn38= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xBVBY0C4090355 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 31 Dec 2019 05:34:00 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) 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.1847.3; Tue, 31 Dec 2019 05:34:00 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 31 Dec 2019 05:34:00 -0600 Received: from a0393678ub.india.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 xBVBXX35024759; Tue, 31 Dec 2019 05:33:55 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas , Andrew Murray , Tom Joseph , Rob Herring , Arnd Bergmann , Jingoo Han , Gustavo Pimentel , Shawn Lin , Heiko Stuebner CC: , , Jonathan Corbet , Greg Kroah-Hartman , , , , Subject: [PATCH 4/7] PCI: endpoint: Add support to link a physical function to a virtual function Date: Tue, 31 Dec 2019 17:05:31 +0530 Message-ID: <20191231113534.30405-5-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191231113534.30405-1-kishon@ti.com> References: <20191231113534.30405-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org 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(+) -- 2.17.1 diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index e7e8367eead1..c18ef626ada5 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -350,6 +350,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); @@ -362,6 +384,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, };