From patchwork Mon Sep 18 19:26:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bryant G. Ly" X-Patchwork-Id: 9957491 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A2AC060385 for ; Mon, 18 Sep 2017 19:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94A7A288E1 for ; Mon, 18 Sep 2017 19:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89689288F3; Mon, 18 Sep 2017 19:27:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B38A288E1 for ; Mon, 18 Sep 2017 19:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750964AbdIRT13 (ORCPT ); Mon, 18 Sep 2017 15:27:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35434 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750886AbdIRT12 (ORCPT ); Mon, 18 Sep 2017 15:27:28 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8IJOWnH104584 for ; Mon, 18 Sep 2017 15:27:28 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d2ea07nw4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 18 Sep 2017 15:27:27 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Sep 2017 15:27:27 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Sep 2017 15:27:23 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8IJRM9G49676372; Mon, 18 Sep 2017 19:27:22 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15EA612403D; Mon, 18 Sep 2017 15:24:39 -0400 (EDT) Received: from bryants-mbp-3.rchland.ibm.com (unknown [9.10.79.138]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 9EA87124037; Mon, 18 Sep 2017 15:24:38 -0400 (EDT) From: "Bryant G. Ly" To: bhelgaas@google.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Bryant G. Ly" , "Juan J . Alvarez" Subject: [PATCH v1 1/3] powerpc/kernel: Split up pci_bus_add_device Date: Mon, 18 Sep 2017 14:26:49 -0500 X-Mailer: git-send-email 2.11.0 (Apple Git-81) In-Reply-To: <20170918192651.78404-1-bryantly@linux.vnet.ibm.com> References: <20170918192651.78404-1-bryantly@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17091819-0048-0000-0000-000001E72724 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007757; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000230; SDB=6.00918923; UDB=6.00461645; IPR=6.00699151; BA=6.00005595; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017199; XFM=3.00000015; UTC=2017-09-18 19:27:25 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091819-0049-0000-0000-0000429A36F0 Message-Id: <20170918192651.78404-2-bryantly@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-18_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709180274 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When enabling SR-IOV one might want to have their own version of starting device drivers for the VFs. This patch allows for SR-IOV callers to use pci_bus_add_virtfn_device instead of generic pci_bus_add_device. When enabling SR-IOV in PSeries architecture the dynamic VFs created within the sriov_configure sysfs call will not load the device driver as firmware will load the device node when the VF device is assigned to the logical partition. So we needed a way to overwrite the way device driver matching is done for virtual functions on powervm. Signed-off-by: Bryant G. Ly Signed-off-by: Juan J. Alvarez --- drivers/pci/bus.c | 51 ++++++++++++++++++++++++++++++++++++++++++--------- drivers/pci/iov.c | 2 +- include/linux/pci.h | 3 +++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index bc56cf19afd3..86daf62c4048 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -302,16 +302,9 @@ void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { } void __weak pcibios_bus_add_device(struct pci_dev *pdev) { } -/** - * pci_bus_add_device - start driver for a single device - * @dev: device to add - * - * This adds add sysfs entries and start device drivers - */ -void pci_bus_add_device(struct pci_dev *dev) -{ - int retval; +void pci_bus_add_sysfs_entries(struct pci_dev *dev) +{ /* * Can not put in pci_device_add yet because resources * are not assigned yet for some devices. @@ -321,6 +314,11 @@ void pci_bus_add_device(struct pci_dev *dev) pci_create_sysfs_dev_files(dev); pci_proc_attach_device(dev); pci_bridge_d3_update(dev); +} + +void pci_bus_match_device_driver(struct pci_dev *dev) +{ + int retval; dev->match_driver = true; retval = device_attach(&dev->dev); @@ -333,6 +331,41 @@ void pci_bus_add_device(struct pci_dev *dev) dev->is_added = 1; } + +#ifdef CONFIG_PCI_IOV +void __weak pci_bus_match_virtfn_driver(struct pci_dev *dev) +{ + pci_bus_match_device_driver(dev); +} + +/** + * pci_bus_add_virtfn_device - start driver for a virtual function device + * @dev: device to add + * + * This adds add sysfs entries and start device drivers for + * virtual function devices + * + */ +void pci_bus_add_virtfn_device(struct pci_dev *pdev) +{ + pci_bus_add_sysfs_entries(pdev); + pci_bus_match_virtfn_driver(pdev); +} +EXPORT_SYMBOL_GPL(pci_bus_add_virtfn_device); +#endif + +/** + * pci_bus_add_device - start driver for a single device + * @dev: device to add + * + * This adds add sysfs entries and start device drivers + */ +void pci_bus_add_device(struct pci_dev *dev) +{ + pci_bus_add_sysfs_entries(dev); + pci_bus_match_device_driver(dev); +} + EXPORT_SYMBOL_GPL(pci_bus_add_device); /** diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index ac41c8be9200..16cc72545847 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -162,7 +162,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id, int reset) pci_device_add(virtfn, virtfn->bus); - pci_bus_add_device(virtfn); + pci_bus_add_virtfn_device(virtfn); sprintf(buf, "virtfn%u", id); rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); if (rc) diff --git a/include/linux/pci.h b/include/linux/pci.h index f68c58a93dd0..39f5c0b4bf23 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -911,6 +911,9 @@ struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); unsigned int pci_scan_child_bus(struct pci_bus *bus); void pci_bus_add_device(struct pci_dev *dev); +#ifdef CONFIG_PCI_IOV +void pci_bus_add_virtfn_device(struct pci_dev *dev); +#endif void pci_read_bridge_bases(struct pci_bus *child); struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);