Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1639830ybv; Fri, 21 Feb 2020 00:49:10 -0800 (PST) X-Google-Smtp-Source: APXvYqztFrNLsw4RkB7FA1BIL9xdGP/zGiHct1qJ/dwHnfNdH+loAaaSxnqVZ7GeaRKUiM4WpaSx X-Received: by 2002:a9d:7ccd:: with SMTP id r13mr26253282otn.56.1582274949723; Fri, 21 Feb 2020 00:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582274949; cv=none; d=google.com; s=arc-20160816; b=ri50ZO1/ISqAa3Z3HJxEDa6yCJrhcjcdeIKgBFr+SzXJ4oYeOQm1o74VbFQZ9eM/aA JGWsmucvhemrfZ0Eqs8BAMWZrKd7tWpx+nUMCU4IhTNsWRqtUi1V7yJNVlKK1fZUyu59 Q8MVsGLVbsGGTWodE8PoWb4J3NoYC3qzvR2GFncFIbiEhzfXxKDq3S7gfkAdl0i70S05 vVWpGSFNWS80jpJDDiZFYQbevo2106YkuzDbDCYrZ/P0L6pVxPgUDEt5S//gQLZgP/X5 ZU48SCmxXFZ0ZsC2fjPvxPj3KlHdfhDqPjUgbluSqXVYquLfxNBEA3PdTeHKCa2ep/cx yU4w== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BvNaM+ht6Nx1z8K8oGTYcAcA3ItTk2MRkwonSahIVTU=; b=oxCnEoKUshSs2/rCJ7s5a1IfeDNe1bP1Vn0tmurGCly4fTM39FPaJWfjzJvf0iw2RZ r1oVVazAjq2qixrDICgYqYiZFuVyXeVkghrYFr7KWza1wZYn+aaewuBvjS3RFdUHeCgi TV+6SpD7CTKHjab7S1ZVaVJxMvD9PeNZnboVDYxd7I9hqKVvOYEn/yLih3BS0eH52rdg vnI5S5vCCCsN+L0q8BovCA8tMlsehY+9iqY2dcd436jrk3sBIyW6octtyt/SV5P4E+bX CUdXfyT0YgAsNVh6UBB1aPMyU1aPYbu+KCYiC+wOtPBaWldmrnAtPPRZSAzebm9zwBNm ER2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z48Q5NCQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si1071609ote.275.2020.02.21.00.48.57; Fri, 21 Feb 2020 00:49:09 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Z48Q5NCQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728812AbgBUHq4 (ORCPT + 99 others); Fri, 21 Feb 2020 02:46:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:42600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728792AbgBUHqy (ORCPT ); Fri, 21 Feb 2020 02:46:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 080DF207FD; Fri, 21 Feb 2020 07:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271213; bh=a3QHIHNxFMx+bv/cC1wgJHLhkTnD8DsRADzbTKuOYRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z48Q5NCQJ1UkkHzeeUg5eSI/SVY2oC9mrOPOdbo3F4rIl/UhfoXIYQvUN5KWOe9yF wTHOj1dlyLtZ37FDgk198OjSGm7e8pe6ieZsij9bLVubWs/qaSFZHNi00MigceGT2x 2eMYTf6qw83/06hfYJvFs9KJzvGrdpsFKtsRBqoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver OHalloran , Alexey Kardashevskiy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.5 082/399] powerpc/iov: Move VF pdev fixup into pcibios_fixup_iov() Date: Fri, 21 Feb 2020 08:36:47 +0100 Message-Id: <20200221072410.308097100@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver O'Halloran [ Upstream commit 965c94f309be58fbcc6c8d3e4f123376c5970d79 ] An ioda_pe for each VF is allocated in pnv_pci_sriov_enable() before the pci_dev for the VF is created. We need to set the pe->pdev pointer at some point after the pci_dev is created. Currently we do that in: pcibios_bus_add_device() pnv_pci_dma_dev_setup() (via phb->ops.dma_dev_setup) /* fixup is done here */ pnv_pci_ioda_dma_dev_setup() (via pnv_phb->dma_dev_setup) The fixup needs to be done before setting up DMA for for the VF's PE, but there's no real reason to delay it until this point. Move the fixup into pnv_pci_ioda_fixup_iov() so the ordering is: pcibios_add_device() pnv_pci_ioda_fixup_iov() (via ppc_md.pcibios_fixup_sriov) pcibios_bus_add_device() ... This isn't strictly required, but it's a slightly more logical place to do the fixup and it simplifies pnv_pci_dma_dev_setup(). Signed-off-by: Oliver O'Halloran Reviewed-by: Alexey Kardashevskiy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200110070207.439-4-oohall@gmail.com Signed-off-by: Sasha Levin --- arch/powerpc/platforms/powernv/pci-ioda.c | 29 +++++++++++++++++++---- arch/powerpc/platforms/powernv/pci.c | 14 ----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 4374836b033b4..67e4628dd5274 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -2900,9 +2900,6 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev) struct pci_dn *pdn; int mul, total_vfs; - if (!pdev->is_physfn || pci_dev_is_added(pdev)) - return; - pdn = pci_get_pdn(pdev); pdn->vfs_expanded = 0; pdn->m64_single_mode = false; @@ -2977,6 +2974,30 @@ truncate_iov: res->end = res->start - 1; } } + +static void pnv_pci_ioda_fixup_iov(struct pci_dev *pdev) +{ + if (WARN_ON(pci_dev_is_added(pdev))) + return; + + if (pdev->is_virtfn) { + struct pnv_ioda_pe *pe = pnv_ioda_get_pe(pdev); + + /* + * VF PEs are single-device PEs so their pdev pointer needs to + * be set. The pdev doesn't exist when the PE is allocated (in + * (pcibios_sriov_enable()) so we fix it up here. + */ + pe->pdev = pdev; + WARN_ON(!(pe->flags & PNV_IODA_PE_VF)); + } else if (pdev->is_physfn) { + /* + * For PFs adjust their allocated IOV resources to match what + * the PHB can support using it's M64 BAR table. + */ + pnv_pci_ioda_fixup_iov_resources(pdev); + } +} #endif /* CONFIG_PCI_IOV */ static void pnv_ioda_setup_pe_res(struct pnv_ioda_pe *pe, @@ -3873,7 +3894,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, ppc_md.pcibios_default_alignment = pnv_pci_default_alignment; #ifdef CONFIG_PCI_IOV - ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources; + ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov; ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment; ppc_md.pcibios_sriov_enable = pnv_pcibios_sriov_enable; ppc_md.pcibios_sriov_disable = pnv_pcibios_sriov_disable; diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index e8e58a2cccddf..8307e1f4086cb 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c @@ -814,20 +814,6 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev) { struct pci_controller *hose = pci_bus_to_host(pdev->bus); struct pnv_phb *phb = hose->private_data; -#ifdef CONFIG_PCI_IOV - struct pnv_ioda_pe *pe; - - /* Fix the VF pdn PE number */ - if (pdev->is_virtfn) { - list_for_each_entry(pe, &phb->ioda.pe_list, list) { - if (pe->rid == ((pdev->bus->number << 8) | - (pdev->devfn & 0xff))) { - pe->pdev = pdev; - break; - } - } - } -#endif /* CONFIG_PCI_IOV */ if (phb && phb->dma_dev_setup) phb->dma_dev_setup(phb, pdev); -- 2.20.1