From patchwork Mon Apr 2 13:29:35 2018 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: 132658 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2580738ljb; Mon, 2 Apr 2018 06:29:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/xVCpG2a2KVTeIS6s7+LlZ2WSpD4hspI8TAgvxlUEGdyU0sdmX3O0+YpSIKL1ZefyHL8a4 X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr9748699plq.207.1522675792207; Mon, 02 Apr 2018 06:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522675792; cv=none; d=google.com; s=arc-20160816; b=FQyM7lC+ztRh3kn7S48RJeCTVw446K1ZAEAlbmLHCBaWPCPfMSdg4QKnKLIEYCVIoG W9c8Y6N1X2c2DDKalQSH0mGiRderSO5t9GGtG+YQj/ydVxZyqc1Pj+rpYcKt1hNxr5kC SHoWfkOGlzEOp3xshJLSUshNXjfPH3PRKLx1O1LYFwao0BZfXiGCdKD13SXtndsav80B kulK/wiqDt89Px2xk3wqGx3zyfff7xEwQAbAkpVGYYUsHLzhpgrwtDc6+zUfQM6DEVI+ nOOTqDGM24Ki8s2w5h8HbWupUn+KKNFECPAbx2oczAZWpvhk82Skr/Z+ykn4evdSYqpk JWqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=qPzWN7nCkNd5Et82RaaMKT0dS5T3VvtI8dQFid971LE=; b=0OsNh8LHzBvlkxqK99rAYv2zLFPNaUNIO6JQU54EYCDK1KsKcSyEgo9c85h4z7UVXh Ga18ipuk6nj2awMBZ48xfmkrh6A88XQeesYNFHY8PBEP7o6bDXjKVyf/D7kONLQ0iTIu 5seHQ6MgIDhpkx4CIqqerUka4aZVcXlZvJttzvPGfp/8FUR8cEoi5rRbRZ2k+BLcrNjd yjX9n5UrbDcWlHUe0IZX1li6nq1591DFRA36ROnZA8ayP0EHweyUjKEMslY8yPV7evd7 XSZ76LBX+iBNXt+ZxE9EiNuB3S41PMvZWjU5IpZzDsEcy3vAcrJouymz0x3zWM4ZMZej 1yQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w4cES7gj; 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 z18si224915pgv.530.2018.04.02.06.29.51; Mon, 02 Apr 2018 06:29:52 -0700 (PDT) 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=w4cES7gj; 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 S1751216AbeDBN3s (ORCPT + 29 others); Mon, 2 Apr 2018 09:29:48 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:43153 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750724AbeDBN3p (ORCPT ); Mon, 2 Apr 2018 09:29:45 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w32DTet6027923; Mon, 2 Apr 2018 08:29:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522675780; bh=R0LgqUUumwzr9IDMAF4iA7pFF03hdzhJjAOCKxGM91c=; h=From:To:CC:Subject:Date; b=w4cES7gjToXQH3bfSwa9MjOSBbUd+Msc7ChoYZ93pv7JtKWg0cdQhpD8mXTtmrFMS h4BcYNkPDmnh/TmlcAsD1UO8kAUkiTDb7759ROkFNpV0q7eK3vdKRkgSThbI8vjTGn +rpG9Xw/V0XYLI3QsythM067Reig6qH/55oDZRAo= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32DTe1Y011856; Mon, 2 Apr 2018 08:29:40 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 2 Apr 2018 08:29:40 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 2 Apr 2018 08:29:40 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32DTbXG007254; Mon, 2 Apr 2018 08:29:38 -0500 From: Kishon Vijay Abraham I To: , Lorenzo Pieralisi , Bjorn Helgaas CC: , , Gustavo Pimentel Subject: [PATCH] PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry Date: Mon, 2 Apr 2018 18:59:35 +0530 Message-ID: <20180402132935.32008-1-kishon@ti.com> X-Mailer: git-send-email 2.16.2 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 In order to be able to provide correct driver_data for pci_epf device, a separate configfs entry for each pci_epf_device_id table entry in pci_epf_driver is required. Add support to create configfs entry for each pci_epf_device_id table entry here. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epf-core.c | 23 +++++++++++++++++++++-- include/linux/pci-epf.h | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) -- 2.16.2 Tested-by: Gustavo Pimentel diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 59ed29e550e9..d6787f39fd41 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -15,6 +15,8 @@ #include #include +static DEFINE_MUTEX(pci_epf_mutex); + static struct bus_type pci_epf_bus_type; static const struct device_type pci_epf_type; @@ -139,7 +141,13 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space); */ void pci_epf_unregister_driver(struct pci_epf_driver *driver) { - pci_ep_cfs_remove_epf_group(driver->group); + struct config_group *group; + + mutex_lock(&pci_epf_mutex); + list_for_each_entry(group, &driver->epf_group, group_entry) + pci_ep_cfs_remove_epf_group(group); + list_del(&driver->epf_group); + mutex_unlock(&pci_epf_mutex); driver_unregister(&driver->driver); } EXPORT_SYMBOL_GPL(pci_epf_unregister_driver); @@ -155,6 +163,8 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, struct module *owner) { int ret; + struct config_group *group; + const struct pci_epf_device_id *id; if (!driver->ops) return -EINVAL; @@ -169,7 +179,16 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, if (ret) return ret; - driver->group = pci_ep_cfs_add_epf_group(driver->driver.name); + INIT_LIST_HEAD(&driver->epf_group); + + id = driver->id_table; + while (id->name[0]) { + group = pci_ep_cfs_add_epf_group(id->name); + mutex_lock(&pci_epf_mutex); + list_add_tail(&group->group_entry, &driver->epf_group); + mutex_unlock(&pci_epf_mutex); + id++; + } return 0; } diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index e897bf076701..a30dcaafa6e8 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -72,7 +72,7 @@ struct pci_epf_ops { * @driver: PCI EPF driver * @ops: set of function pointers for performing EPF operations * @owner: the owner of the module that registers the PCI EPF driver - * @group: configfs group corresponding to the PCI EPF driver + * @epf_group: list of configfs group corresponding to the PCI EPF driver * @id_table: identifies EPF devices for probing */ struct pci_epf_driver { @@ -82,7 +82,7 @@ struct pci_epf_driver { struct device_driver driver; struct pci_epf_ops *ops; struct module *owner; - struct config_group *group; + struct list_head epf_group; const struct pci_epf_device_id *id_table; };