From patchwork Thu Sep 5 19:13:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 11133825 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D720A924 for ; Thu, 5 Sep 2019 19:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 076F62082E for ; Thu, 5 Sep 2019 19:13:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=anastas.io header.i=@anastas.io header.b="eJiz/bNf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387413AbfIETN5 (ORCPT ); Thu, 5 Sep 2019 15:13:57 -0400 Received: from alpha.anastas.io ([104.248.188.109]:54973 "EHLO alpha.anastas.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbfIETN5 (ORCPT ); Thu, 5 Sep 2019 15:13:57 -0400 Received: from authenticated-user (alpha.anastas.io [104.248.188.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by alpha.anastas.io (Postfix) with ESMTPSA id 3818C7E74E; Thu, 5 Sep 2019 14:13:56 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=anastas.io; s=mail; t=1567710836; bh=jkDnyyJxLCKRf9Hh3sYC8Cvd+CcM72dsoaJ1/VZoyXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eJiz/bNfIq2gq62s8P6uE/cX9dvr2amsxdM1sSH4w9JN1qcmXpWwCfbYM4BybXt0p CpEGqgHoVksQl5NNTNqVMiwNiQw0eQDILY37Rra9soEYrYxWMJlqXJOV4LpG9TDWpP /Ooz0aPiRe3GMswgMwGGKbClH8EDxvsqET0mp5YXTP+we/Dr6ko4TuCNtQjz0vqTks hjuvtfGwl1d9oiLuyPn9iBucUW5tMu1lMw7vJ4aBeM7969LOs8JLDINa7exg0sEwNK kEAvb618MyrVplHG8aEEY20rQoulLuDQQyLG5ll0MH06//ZHmibs2LTg8susmD4GEE XqUT832Kx2H3g== From: Shawn Anastasio To: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: bhelgaas@google.com, mpe@ellerman.id.au, aik@ozlabs.ru, benh@kernel.crashing.org, sbobroff@linux.ibm.com, oohall@gmail.com, lukas@wunner.de Subject: [PATCH v2 1/1] powerpc/pci: Fix pcibios_setup_device() ordering Date: Thu, 5 Sep 2019 14:13:43 -0500 Message-Id: <20190905191343.2919-2-shawn@anastas.io> In-Reply-To: <20190905191343.2919-1-shawn@anastas.io> References: <20190905191343.2919-1-shawn@anastas.io> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Move PCI device setup from pcibios_add_device() and pcibios_fixup_bus() to pcibios_bus_add_device(). This ensures that platform-specific DMA and IOMMU setup occurs after the device has been registered in sysfs, which is a requirement for IOMMU group assignment to work This fixes IOMMU group assignment for hotplugged devices on pseries, where the existing behavior results in IOMMU assignment before registration. Thanks to Lukas Wunner for the suggestion. Signed-off-by: Shawn Anastasio --- arch/powerpc/kernel/pci-common.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index f627e15bb43c..d119c77efb69 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -261,12 +261,6 @@ int pcibios_sriov_disable(struct pci_dev *pdev) #endif /* CONFIG_PCI_IOV */ -void pcibios_bus_add_device(struct pci_dev *pdev) -{ - if (ppc_md.pcibios_bus_add_device) - ppc_md.pcibios_bus_add_device(pdev); -} - static resource_size_t pcibios_io_size(const struct pci_controller *hose) { #ifdef CONFIG_PPC64 @@ -987,15 +981,17 @@ static void pcibios_setup_device(struct pci_dev *dev) ppc_md.pci_irq_fixup(dev); } -int pcibios_add_device(struct pci_dev *dev) +void pcibios_bus_add_device(struct pci_dev *pdev) { - /* - * We can only call pcibios_setup_device() after bus setup is complete, - * since some of the platform specific DMA setup code depends on it. - */ - if (dev->bus->is_added) - pcibios_setup_device(dev); + /* Perform platform-specific device setup */ + pcibios_setup_device(pdev); + + if (ppc_md.pcibios_bus_add_device) + ppc_md.pcibios_bus_add_device(pdev); +} +int pcibios_add_device(struct pci_dev *dev) +{ #ifdef CONFIG_PCI_IOV if (ppc_md.pcibios_fixup_sriov) ppc_md.pcibios_fixup_sriov(dev); @@ -1037,9 +1033,6 @@ void pcibios_fixup_bus(struct pci_bus *bus) /* Now fixup the bus bus */ pcibios_setup_bus_self(bus); - - /* Now fixup devices on that bus */ - pcibios_setup_bus_devices(bus); } EXPORT_SYMBOL(pcibios_fixup_bus);