All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 08/12] dm: pci: Remove the unnecessary pci_bus_find_devfn() in pci_bind_bus_devices()
Date: Fri, 21 Aug 2015 17:27:36 -0600	[thread overview]
Message-ID: <CAPnjgZ0Cex=3VfuFc87Mtr8FTh5QPvRincSkO4XzBuXDRh8Yww@mail.gmail.com> (raw)
In-Reply-To: <1440078028-29464-9-git-send-email-bmeng.cn@gmail.com>

Hi Bin,

On 20 August 2015 at 07:40, Bin Meng <bmeng.cn@gmail.com> wrote:
> During pci_bind_bus_devices() before finding a proper driver to bind
> the device, pci_bus_find_devfn() is called to find if this device
> already exists. However since device is even not bound, this call
> always returns -ENODEV. It is really unnecessary hence remove it.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
>  drivers/pci/pci-uclass.c | 35 ++++++++++++++---------------------
>  1 file changed, 14 insertions(+), 21 deletions(-)

This doesn't look quite right to me.

The way this is supposed to work is that when the bus or bridge is
bound, pci_uclass_post_bind() should add a device for each node it
finds in the device tree on that bus.

I think the problem in your case is that in crownbay.dts you have:

pcie at 17,0 {
  #address-cells = <3>;
  #size-cells = <2>;
  compatible = "intel,pci";
  device_type = "pci";

and the compatible string for this doesn't match any driver. Thus the
serial ports are never 'seen' during the initial bind and devices are
not created.

If you add a driver for your device 17 and have it call
dm_scan_fdt_node() then the devices should be bound correctly.

I think then your new code may not be needed, or a small smaller
change may be needed.

>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index c90e7ac..63e85b9 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -551,6 +551,8 @@ int pci_bind_bus_devices(struct udevice *bus)
>         ulong header_type;
>         pci_dev_t bdf, end;
>         bool found_multi;
> +       struct pci_device_id find_id;
> +       ulong val;
>         int ret;
>
>         found_multi = false;
> @@ -585,30 +587,21 @@ int pci_bind_bus_devices(struct udevice *bus)
>                                     PCI_SIZE_32);
>                 class >>= 8;
>
> -               /* Find this device in the device tree */
> -               ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);
> -
>                 /* Search for a driver */
>
> -               /* If nothing in the device tree, bind a generic device */
> -               if (ret == -ENODEV) {
> -                       struct pci_device_id find_id;
> -                       ulong val;
> -
> -                       memset(&find_id, '\0', sizeof(find_id));
> -                       find_id.vendor = vendor;
> -                       find_id.device = device;
> -                       find_id.class = class;
> -                       if ((header_type & 0x7f) == PCI_HEADER_TYPE_NORMAL) {
> -                               pci_bus_read_config(bus, bdf,
> -                                                   PCI_SUBSYSTEM_VENDOR_ID,
> -                                                   &val, PCI_SIZE_32);
> -                               find_id.subvendor = val & 0xffff;
> -                               find_id.subdevice = val >> 16;
> -                       }
> -                       ret = pci_find_and_bind_driver(bus, &find_id, bdf,
> -                                                      &dev);
> +               memset(&find_id, '\0', sizeof(find_id));
> +               find_id.vendor = vendor;
> +               find_id.device = device;
> +               find_id.class = class;
> +               if ((header_type & 0x7f) == PCI_HEADER_TYPE_NORMAL) {
> +                       pci_bus_read_config(bus, bdf,
> +                                           PCI_SUBSYSTEM_VENDOR_ID,
> +                                           &val, PCI_SIZE_32);
> +                       find_id.subvendor = val & 0xffff;
> +                       find_id.subdevice = val >> 16;
>                 }
> +               ret = pci_find_and_bind_driver(bus, &find_id, bdf,
> +                                              &dev);
>                 if (ret)
>                         return ret;
>
> --
> 1.8.2.1
>

Regards,
Simon

  reply	other threads:[~2015-08-21 23:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 13:40 [U-Boot] [PATCH v2 00/12] x86: dm: pci: Support pci uart devices with driver model Bin Meng
2015-08-20 13:40 ` [U-Boot] [PATCH v2 01/12] dm: pci: Support selected device/driver binding before relocation Bin Meng
2015-08-22  4:20   ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 02/12] x86: fsp: Delay x86_fsp_init() call a little bit Bin Meng
2015-08-22  4:20   ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 03/12] x86: fsp: Enlarge the size of malloc() pool before relocation Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-22  4:20     ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 04/12] x86: fsp: Add comments about U-Boot entering start.S twice Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-22  4:20     ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 05/12] x86: queensbay: Move unprotect_spi_flash() to arch_misc_init() Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-22  4:20     ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 06/12] x86: baytrail: Remove the fsp_init_phase_pci() call Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-22  4:20     ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 07/12] x86: fsp: Call fsp_init_phase_pci() in pci_uclass_post_probe() Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-22  9:05     ` Bin Meng
2015-08-23 21:21       ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 08/12] dm: pci: Remove the unnecessary pci_bus_find_devfn() in pci_bind_bus_devices() Bin Meng
2015-08-21 23:27   ` Simon Glass [this message]
2015-08-20 13:40 ` [U-Boot] [PATCH v2 09/12] fdtdec: Fix possible infinite loop in fdtdec_get_pci_vendev() Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-23 21:22     ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 10/12] dm: pci: Save devfn without bus number in pci_uclass_child_post_bind() Bin Meng
2015-08-21 23:27   ` Simon Glass
2015-08-23 21:22     ` Simon Glass
2015-08-20 13:40 ` [U-Boot] [PATCH v2 11/12] dm: pci: Really support binding pci device in the device tree Bin Meng
2015-08-20 13:40 ` [U-Boot] [PATCH v2 12/12] dm: pci: Document binding of pci device drivers Bin Meng

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='CAPnjgZ0Cex=3VfuFc87Mtr8FTh5QPvRincSkO4XzBuXDRh8Yww@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.