Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4089265pxb; Mon, 1 Feb 2021 12:07:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxafw0iOLIBVdtWq26cBojzl2pDYxNzVnd442VDAu4ewj44R7foYnEwQT51THfLw5npBs4m X-Received: by 2002:a17:906:ff43:: with SMTP id zo3mr19410723ejb.542.1612210067740; Mon, 01 Feb 2021 12:07:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612210067; cv=none; d=google.com; s=arc-20160816; b=yXun9CiBBtxNDlqRA1IJKYWXaY3nhA3wLdu/B3C0v7byXMJtYbELpfBfeFwQwZWZPa rdkclxCQD74ny21otICUXrH5nMplkDlSwvMxYYc3odpwFazkcqBp2A+SMzYBMUvC7H9I R6OwjjZCDpRqI5euIkCni293dj0D55V5RzMABKALm+P7ZTJdcDded6Fp2q82g999z/xw jHmPHjk1c6VxUAwdWx88tb/btWzMfqvEZ4n6F14bek8cuY4bYeBla6v8iTxAp2LfhBvN TtSsgpaLbL/i3EmjF44pqvX/xX+Qz3/Jj5Ee/iglYpM5hETrJlZhLZWR7OZzZjD+lkWR +g2A== 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=W2hIRAuaicwnwQ2V4WeqFD+v8jC741BDEBbw/DKI5hY63JX2o92RHCrkDO+2Db53o9 2HnND3AB38w9u5O62EVh2vE4hMQfd4RYHS8y5iXXhiaGMh0o1UNXjTH5BBBHDh5wCGQe goyHIw2dD0vvL3R0R+HsX3KzD+UlGKfAzmtWO9jhf/VLyLBSf78+VFrdZbZiibz5pgLS ilXRlWmUws/HMy81vglQM2akBkskmHLVgzf6HxevoGMYvlUZ/hr3aQWOcoAXcgwKfvMx /gLm35ntKM7PLknuLHoVc9J1rQD35eSpzx4cQuBCWekuWBS3hQf0Czl4nKAfSl9f/G4y IzAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PDDyciFe; 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 dj14si10798040edb.210.2021.02.01.12.07.21; Mon, 01 Feb 2021 12:07:47 -0800 (PST) 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=PDDyciFe; 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 S232675AbhBAUE0 (ORCPT + 99 others); Mon, 1 Feb 2021 15:04:26 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:41694 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbhBAUAx (ORCPT ); Mon, 1 Feb 2021 15:00:53 -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 111Jx6mB023954; Mon, 1 Feb 2021 13:59:06 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1612209546; bh=lTz57oIbDoqLeHnWKHJxRenng3YXT0XKq15ddYdluKo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PDDyciFeY3vlbeAtvFdAMoz7O8pK627sDKGwejCwAJI4cb/vIKr5deHz2QnrJK6pc eDEq2GdKRiUtfzGyxU/gzq/34stQwrIaQZr4Jb+X5VOWCiLld057fpyDXCWO3wBpPs F0HuWSOU7y4PH+7zLPvC+yO537nvbtiaqxfozDS0= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 111Jx67I042894 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 Feb 2021 13:59:06 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) 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; Mon, 1 Feb 2021 13:59:05 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE100.ent.ti.com (157.170.170.30) 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; Mon, 1 Feb 2021 13:59:05 -0600 Received: from a0393678-ssd.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 111JwAQg085814; Mon, 1 Feb 2021 13:59:00 -0600 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 v11 09/17] PCI: endpoint: Add pci_epf_ops for epf drivers to expose function specific attrs Date: Tue, 2 Feb 2021 01:28:01 +0530 Message-ID: <20210201195809.7342-10-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210201195809.7342-1-kishon@ti.com> References: <20210201195809.7342-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