linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-pci@vger.kernel.org,
	Gabriele Paoloni <gabriele.paoloni@huawei.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Tomasz Nowicki <tn@semihalf.com>, Duc Dang <dhdang@apm.com>,
	Sinan Kaya <okaya@codeaurora.org>,
	Christopher Covington <cov@codeaurora.org>,
	Dongdong Liu <liudongdong3@huawei.com>
Subject: Re: [PATCH v11 05/15] arm64: PCI: Manage controller-specific data on per-controller basis
Date: Tue, 6 Dec 2016 15:45:03 +0000	[thread overview]
Message-ID: <20161206154503.GB4601@red-moon> (raw)
In-Reply-To: <20161205232557.3957.84754.stgit@bhelgaas-glaptop.roam.corp.google.com>

On Mon, Dec 05, 2016 at 05:25:57PM -0600, Bjorn Helgaas wrote:
> From: Tomasz Nowicki <tn@semihalf.com>
> 
> Currently we use one shared global acpi_pci_root_ops structure to keep
> controller-specific ops. We pass its pointer to acpi_pci_root_create() and
> associate it with a host bridge instance for good.  Such a design implies
> serious drawback. Any potential manipulation on the single system-wide
> acpi_pci_root_ops leads to kernel crash. The structure content is not
> really changing even across multiple host bridges creation; thus it was not
> an issue so far.
> 
> In preparation for adding ECAM quirks mechanism (where controller-specific
> PCI ops may be different for each host bridge) allocate new
> acpi_pci_root_ops and fill in with data for each bridge. Now it is safe to
> have different controller-specific info. As a consequence free
> acpi_pci_root_ops when host bridge is released.
> 
> No functional changes in this patch.
> 
> Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/arm64/kernel/pci.c |   17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)

Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 7909f59..1eb42ba 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -169,33 +169,36 @@ static void pci_acpi_generic_release_info(struct acpi_pci_root_info *ci)
>  
>  	ri = container_of(ci, struct acpi_pci_generic_root_info, common);
>  	pci_ecam_free(ri->cfg);
> +	kfree(ci->ops);
>  	kfree(ri);
>  }
>  
> -static struct acpi_pci_root_ops acpi_pci_root_ops = {
> -	.release_info = pci_acpi_generic_release_info,
> -};
> -
>  /* Interface called from ACPI code to setup PCI host controller */
>  struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  {
>  	int node = acpi_get_node(root->device->handle);
>  	struct acpi_pci_generic_root_info *ri;
>  	struct pci_bus *bus, *child;
> +	struct acpi_pci_root_ops *root_ops;
>  
>  	ri = kzalloc_node(sizeof(*ri), GFP_KERNEL, node);
>  	if (!ri)
>  		return NULL;
>  
> +	root_ops = kzalloc_node(sizeof(*root_ops), GFP_KERNEL, node);
> +	if (!root_ops)
> +		return NULL;
> +
>  	ri->cfg = pci_acpi_setup_ecam_mapping(root);
>  	if (!ri->cfg) {
>  		kfree(ri);
> +		kfree(root_ops);
>  		return NULL;
>  	}
>  
> -	acpi_pci_root_ops.pci_ops = &ri->cfg->ops->pci_ops;
> -	bus = acpi_pci_root_create(root, &acpi_pci_root_ops, &ri->common,
> -				   ri->cfg);
> +	root_ops->release_info = pci_acpi_generic_release_info;
> +	root_ops->pci_ops = &ri->cfg->ops->pci_ops;
> +	bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg);
>  	if (!bus)
>  		return NULL;
>  
> 

  reply	other threads:[~2016-12-06 15:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 23:25 [PATCH v11 00/15] PCI: ARM64 ECAM quirks Bjorn Helgaas
2016-12-05 23:25 ` [PATCH v11 01/15] ACPI: Add acpi_resource_consumer() to find device that claims a resource Bjorn Helgaas
2016-12-05 23:25 ` [PATCH v11 02/15] x86/PCI: Use acpi_resource_consumer() to search ACPI namespace for MMCFG Bjorn Helgaas
2016-12-05 23:25 ` [PATCH v11 03/15] arm64: PCI: Add local struct device pointers Bjorn Helgaas
2016-12-06 16:02   ` Lorenzo Pieralisi
2016-12-05 23:25 ` [PATCH v11 04/15] arm64: PCI: Search ACPI namespace to ensure ECAM space is reserved Bjorn Helgaas
2016-12-06 16:01   ` Lorenzo Pieralisi
2016-12-05 23:25 ` [PATCH v11 05/15] arm64: PCI: Manage controller-specific data on per-controller basis Bjorn Helgaas
2016-12-06 15:45   ` Lorenzo Pieralisi [this message]
2016-12-05 23:26 ` [PATCH v11 06/15] arm64: PCI: Exclude ACPI "consumer" resources from host bridge windows Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 07/15] PCI/ACPI: Extend pci_mcfg_lookup() to return ECAM config accessors Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 08/15] PCI/ACPI: Check for platform-specific MCFG quirks Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 09/15] PCI/ACPI: Provide acpi_get_rc_resources() for ARM64 platform Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 10/15] PCI: Add MCFG quirks for Qualcomm QDF2432 host controller Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 11/15] PCI: Add MCFG quirks for HiSilicon Hip05/06/07 host controllers Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 12/15] PCI: thunder-pem: Factor out resource lookup Bjorn Helgaas
2016-12-05 23:26 ` [PATCH v11 13/15] PCI: Add MCFG quirks for Cavium ThunderX pass2.x host controller Bjorn Helgaas
2016-12-06 13:07   ` Tomasz Nowicki
2016-12-06 20:45     ` Bjorn Helgaas
2016-12-07 12:23       ` Tomasz Nowicki
2016-12-05 23:27 ` [PATCH v11 14/15] PCI: Add MCFG quirks for Cavium ThunderX pass1.x " Bjorn Helgaas
2016-12-05 23:27 ` [PATCH v11 15/15] PCI: Add MCFG quirks for X-Gene " Bjorn Helgaas
2016-12-06  2:14 ` [PATCH v11 00/15] PCI: ARM64 ECAM quirks Duc Dang
2016-12-06  7:16 ` Dongdong Liu
2016-12-06 14:41 ` Tomasz Nowicki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161206154503.GB4601@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=cov@codeaurora.org \
    --cc=dhdang@apm.com \
    --cc=gabriele.paoloni@huawei.com \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liudongdong3@huawei.com \
    --cc=okaya@codeaurora.org \
    --cc=rafael@kernel.org \
    --cc=tn@semihalf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).