Received: by 10.213.65.68 with SMTP id h4csp764140imn; Fri, 6 Apr 2018 08:30:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx489xWnTNguEusSmSohWP3qqvHYbJVorOzRCWZKbrf1iLM8//sWQ5qERUZONueBcLNsV8+cz X-Received: by 2002:a17:902:9001:: with SMTP id a1-v6mr27085943plp.211.1523028631245; Fri, 06 Apr 2018 08:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523028631; cv=none; d=google.com; s=arc-20160816; b=m4LRzzyhjDIt+ZaH90dbNFA9/W9QGfjmNXRR2OY/rvETRblysk6NAw1sNYVvLynpKe Z1eG4sRQti6tsnUaTi0JmsJmQb7Sbq3OaR9atnzVT0p6NvUOMoz1OhuPY/NgMq3QnYqN Snyuyd2mS1yjF5f40Qy5zreh1t6H9soMhKujyNMZ1t4c0dpVUgZyTBlnf/Tr7VTOyftk cupBd7yBqB6oZtKTR/PNoJT8h3FJF0vL56EGebL2Yg2JrAlM98HMUn1haL7F9P1brfSQ fEYNDWzYz7oE6rXdS2if5Tks0Vn9E8ye+JWPpP43a+msm7oJNMH0rBjxF7piRXaqQfff BEFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=FspCwbyVKJLZ5ZkvQaqUBXBipIAA0xzh9HwEgQfHMG0=; b=cwQJiQlCcq+98LBFBXpGgy7xIz/f/MGyTzmGuN0A9aQyNCmzpS2I86iYpdEl2iyfXJ ezoWyd+NipN4PKOi9ugA2otde1qzpH4UWi5/DetKR5Lfh1Z2gGNkVbrHTxyTRqte4grx L2LwcYabtt4egzg0YU3IcT3mJejTTZTueqYQMgqeCjBUYpEBKbjZmKDmYBeiOzmgNN8S Z+83ZNVBb84dVgIpth4cRe7IRvAdUmxB+5TFey0tAUn475dPh9CCsAX37A1JyYqibDoz jFxHuCaxBvFH1CHapn0rJfKazeSw/bU+fycPyGw5DDUTo6dAAkWSi3g1CseIdw7TlSHt t6og== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k63si8155205pfh.372.2018.04.06.08.30.17; Fri, 06 Apr 2018 08:30:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752939AbeDFP2r (ORCPT + 99 others); Fri, 6 Apr 2018 11:28:47 -0400 Received: from smtprelay4.synopsys.com ([198.182.47.9]:47629 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752517AbeDFP2o (ORCPT ); Fri, 6 Apr 2018 11:28:44 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0413824E0CC6; Fri, 6 Apr 2018 08:28:44 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id DE7DA328B; Fri, 6 Apr 2018 08:28:43 -0700 (PDT) Received: from pt02.synopsys.com (pt02.internal.synopsys.com [10.107.23.240]) by mailhost.synopsys.com (Postfix) with ESMTP id 645CE3280; Fri, 6 Apr 2018 08:28:43 -0700 (PDT) Received: from [127.0.0.1] (gustavo-e7480.internal.synopsys.com [10.107.25.102]) by pt02.synopsys.com (Postfix) with ESMTP id 89C2F3DA4F; Fri, 6 Apr 2018 16:28:42 +0100 (WEST) Subject: Re: [PATCH] PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20180402132935.32008-1-kishon@ti.com> From: Gustavo Pimentel Message-ID: <29e8dcb0-32f9-a05a-4351-07845d43ee33@synopsys.com> Date: Fri, 6 Apr 2018 16:27:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180402132935.32008-1-kishon@ti.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kishon, On 02/04/2018 14:29, Kishon Vijay Abraham I wrote: > 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(-) > > 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; > }; > > Works like a charm. :) Tested-by: Gustavo Pimentel