Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4666650pxk; Wed, 30 Sep 2020 08:39:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzDiv0efVuC2kDD6rKUTBS8iAj6AwQmQphK/CLfZAzO8K8lbLe5tFtYOC9VwrKNfmB0M6O X-Received: by 2002:a17:906:5402:: with SMTP id q2mr3360478ejo.316.1601480388506; Wed, 30 Sep 2020 08:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601480388; cv=none; d=google.com; s=arc-20160816; b=Xz3rziVl9+FX2XGSN5eWLgcyJkMKBS8AMhLHnTtURl2isy6Tw3v9UmuqEBdrxqg3/R CEgfMsC5/Hj86Ic/5HQ0dfTBYaHvRjiHvIzYap+tFsale417qUP7pcrJeIG/MRj2ZzIR mOtn4T1Q7mcCSAkcGGrSTHCrCJhrDYn+CtYl6Fux7cue2+d0NwXJNUwmQGySmqUmHO0F iSBbKi51P/xo63DCNMLazKWV53tQU5v2mKFeoo3D1WR2If90UK7TUkGLg0ShsdFnOs+y w2OEW1JyB7UTqMRk1wCNeuJimOoWQBPqO9tVxlqgMUDxV00jg+qZxhcqKy2zzWR5B7Ef DW1w== 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=lTz57oIbDoqLeHnWKHJxRenng3YXT0XKq15ddYdluKo=; b=DP7j6t6zQeBM9Q9i0ORIhQCMYQEFrC+d82rejnJyWteZYlcuj00d2JpXXP9QlU57P6 vmRMonrhUN5ICJB1sDdmvzjy81A7jQEQb6/TSYdJ+Pz3NzloWFe9OBPXRCMJNB8z4BZr iy/VRqz2dgeb9Hw+Xmsq3PYXUwz8gjEL9YmQjXyViAFuwM+Ujqy07fLjx70cumZPpHLI gnXOwuB5/wC5CTKIGvEU0XDVIJ2744QinbkTKkWF1kltNv5JXt+NhIgmguX7PBs4r95O U/hf7SkUAI9r3+aAcqw0Qw/swnuBp3a4KaCb99Fvtd0z8feMYKmgEpl6b65w1IwESPfO Y7zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=iOK6cbWo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o8si1195943eji.35.2020.09.30.08.39.24; Wed, 30 Sep 2020 08:39:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=iOK6cbWo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1731025AbgI3Pgl (ORCPT + 99 others); Wed, 30 Sep 2020 11:36:41 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:47626 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729175AbgI3Pgk (ORCPT ); Wed, 30 Sep 2020 11:36:40 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 08UFaSwB076644; Wed, 30 Sep 2020 10:36:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1601480188; bh=lTz57oIbDoqLeHnWKHJxRenng3YXT0XKq15ddYdluKo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=iOK6cbWoFTAR0RV/Ef4vb6qRvVxGXi09P67vyVXCD5TPjG7+SODX8WgfPwitmpcsJ VGn4opZap3azSs4CZpHpPPA5QQOMOPY07ycKWh0vVi7V2uq1ltYOnOT3r4Y7GeBdga r7vsxMHlbJVL4pA971zWLfR8DQJR5pwRnGK83TOU= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 08UFaSED024588 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 Sep 2020 10:36:28 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 30 Sep 2020 10:36:28 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE105.ent.ti.com (157.170.170.35) 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; Wed, 30 Sep 2020 10:36:28 -0500 Received: from a0393678-ssd.dal.design.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 08UFZLZY033254; Wed, 30 Sep 2020 10:36:23 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Jonathan Corbet , Kishon Vijay Abraham I , Lorenzo Pieralisi , Arnd Bergmann , Jon Mason , Dave Jiang , Allen Hubbe , Tom Joseph , Rob Herring CC: Greg Kroah-Hartman , , , , Subject: [PATCH v7 09/18] PCI: endpoint: Add pci_epf_ops for epf drivers to expose function specific attrs Date: Wed, 30 Sep 2020 21:05:10 +0530 Message-ID: <20200930153519.7282-10-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930153519.7282-1-kishon@ti.com> References: <20200930153519.7282-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In addition to the attributes that are generic across function drivers documented in Documentation/PCI/endpoint/pci-endpoint-cfs.rst, there could be function specific attributes that has to be exposed by the function driver to be configured by the user. Add ->add_cfs() in pci_epf_ops to be populated by the function driver if it has to expose any function specific attributes and pci_epf_type_add_cfs() to be invoked by pci-ep-cfs.c when sub-directory to main function directory is created. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epf-core.c | 32 +++++++++++++++++++++++++++++ include/linux/pci-epf.h | 5 +++++ 2 files changed, 37 insertions(+) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 79329ec6373c..7646c8660d42 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -20,6 +20,38 @@ static DEFINE_MUTEX(pci_epf_mutex); static struct bus_type pci_epf_bus_type; static const struct device_type pci_epf_type; +/** + * pci_epf_type_add_cfs() - Help function drivers to expose function specific + * attributes in configfs + * @epf: the EPF device that has to be configured using configfs + * @group: the parent configfs group (corresponding to entries in + * pci_epf_device_id) + * + * Invoke to expose function specific attributes in configfs. If the function + * driver does not have anything to expose (attributes configured by user), + * return NULL. + */ +struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf, + struct config_group *group) +{ + struct config_group *epf_type_group; + + if (!epf->driver) { + dev_err(&epf->dev, "epf device not bound to driver\n"); + return NULL; + } + + if (!epf->driver->ops->add_cfs) + return NULL; + + mutex_lock(&epf->lock); + epf_type_group = epf->driver->ops->add_cfs(epf, group); + mutex_unlock(&epf->lock); + + return epf_type_group; +} +EXPORT_SYMBOL_GPL(pci_epf_type_add_cfs); + /** * pci_epf_unbind() - Notify the function driver that the binding between the * EPF device and EPC device has been lost diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 1dc66824f5a8..b241e7dd171f 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -62,10 +62,13 @@ struct pci_epf_header { * @bind: ops to perform when a EPC device has been bound to EPF device * @unbind: ops to perform when a binding has been lost between a EPC device * and EPF device + * @add_cfs: ops to initialize function specific configfs attributes */ struct pci_epf_ops { int (*bind)(struct pci_epf *epf); void (*unbind)(struct pci_epf *epf); + struct config_group *(*add_cfs)(struct pci_epf *epf, + struct config_group *group); }; /** @@ -188,4 +191,6 @@ void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar, enum pci_epc_interface_type type); int pci_epf_bind(struct pci_epf *epf); void pci_epf_unbind(struct pci_epf *epf); +struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf, + struct config_group *group); #endif /* __LINUX_PCI_EPF_H */ -- 2.17.1