public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Jayachandran C <jchandra@broadcom.com>,
	linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	linux-acpi@vger.kernel.org, Tomasz Nowicki <tn@semihalf.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Subject: Re: [RFC PATCH v3 2/5] arm64: pci: Add ACPI support
Date: Wed, 16 Dec 2015 15:24:12 +0100	[thread overview]
Message-ID: <3216037.gpgqE0G0oj@wuerfel> (raw)
In-Reply-To: <1450269755-21420-3-git-send-email-jchandra@broadcom.com>

On Wednesday 16 December 2015 18:12:32 Jayachandran C wrote:
> @@ -48,9 +49,22 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
>         if (pci_has_flag(PCI_PROBE_ONLY))
>                 return 0;
>  
> +#ifdef CONFIG_ACPI
> +       if (acpi_find_root_bridge_handle(dev))
> +               acpi_pci_irq_enable(dev);
> +#endif
> +
>         return pci_enable_resources(dev, mask);
>  }
>  
> +void pcibios_disable_device(struct pci_dev *dev)
> +{
> +#ifdef CONFIG_ACPI
> +       if (acpi_find_root_bridge_handle(dev))
> +               acpi_pci_irq_disable(dev);
> +#endif
> +}
> +

Can you just move this into the PCI core code? Adding more stuff here
just makes it harder to kill off the existing functions.

>  #ifdef CONFIG_ACPI
> -/* Root bridge scanning */
> -struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
> +
> +void pcibios_add_bus(struct pci_bus *bus)
> +{
> +       acpi_pci_add_bus(bus);
> +}
> +
> +void pcibios_remove_bus(struct pci_bus *bus)
> +{
> +       acpi_pci_remove_bus(bus);
> +}
> +
> +int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
> +{
> +       /* ACPI root bus is created with NULL parent */
> +       if (!acpi_disabled && bridge->dev.parent == NULL) {
> +               struct pci_bus *b = bridge->bus;
> +               struct acpi_pci_root_info *ci = b->sysdata;
> +
> +               ACPI_COMPANION_SET(&bridge->dev, ci->bridge);
> +               b->domain_nr = ci->root->segment;
> +       }
> +       return 0;
> +}
> +

Same here: these functions are identical for all architectures
that use ACPI, so just move the code into PCI core and be done with
it. This means we can even kill off all pcibios_add_bus and
pcibios_remove_bus completely, and pcibios_root_bridge_prepare
will only be needed for powerpc/pseries.

>  /*
> - * raw_pci_read/write - Platform-specific PCI config space access.
> + * ACPI uses these - leave it to the generic ACPI PCI driver
>   */
> -int raw_pci_read(unsigned int domain, unsigned int bus,
> +int __weak raw_pci_read(unsigned int domain, unsigned int bus,
>                   unsigned int devfn, int reg, int len, u32 *val)
>  {
>         return -ENXIO;
>  }
>  
> -int raw_pci_write(unsigned int domain, unsigned int bus,
> +int __weak raw_pci_write(unsigned int domain, unsigned int bus,
>                 unsigned int devfn, int reg, int len, u32 val)
>  {
>         return -ENXIO;
>  }
>  
> +/*
> + * Provide weak implementations of ACPI PCI hooks needed.
> + * Leave it to the ACPI PCI driver implementation to do it
> + */
> +struct pci_bus *__weak pci_acpi_scan_root(struct acpi_pci_root *root)
>  {
> -       /* TODO: Should be revisited when implementing PCI on ACPI */
>         return NULL;
>  }
> +
> +void __init __weak pci_mmcfg_late_init(void)
> +{
> +}

Please don't add __weak functions in architecture code that you expect
a driver to override. Just call it directly if it's configured and
make sure that it doesn't get called if it's not there. If both the
caller and the callee are in generic code, you can leave the architecture
out of this.

> +static int __init pcibios_assign_resources(void)
> +{
> +       pci_assign_unassigned_resources();
> +       return 0;
> +}
> +
> +fs_initcall(pcibios_assign_resources);

This doesn't work for PCI host drivers in loadable modules.

	Arnd

  reply	other threads:[~2015-12-16 14:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-16 12:42 [RFC PATCH v3 0/5] Simple ACPI based PCI support for arm64 Jayachandran C
2015-12-16 12:42 ` [RFC PATCH v3 1/5] ACPI: MCFG: Move mmcfg_list management to drivers/acpi Jayachandran C
2015-12-16 12:42 ` [RFC PATCH v3 2/5] arm64: pci: Add ACPI support Jayachandran C
2015-12-16 14:24   ` Arnd Bergmann [this message]
2015-12-16 12:42 ` [RFC PATCH v3 3/5] PCI: Handle NULL parent in pci_bus_assign_domain_nr Jayachandran C
2015-12-16 12:42 ` [RFC PATCH v3 4/5] ACPI: PCI: Support platforms that need pci_remap_iospace Jayachandran C
2015-12-16 12:42 ` [RFC PATCH v3 5/5] PCI: ACPI: Add a generic ACPI based host controller Jayachandran C
2015-12-18 10:35   ` Arnd Bergmann

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=3216037.gpgqE0G0oj@wuerfel \
    --to=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=jchandra@broadcom.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --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