diff mbox series

[007/108] dm: pci: Allow disabling auto-config for a device

Message ID 20200126220508.7.I66a7bcb7db931e196e8319d2dbca4e418274f39b@changeid
State RFC
Delegated to: Bin Meng
Headers show
Series RFC: dm: Add programatic generation of ACPI tables | expand

Commit Message

Simon Glass Jan. 27, 2020, 5:05 a.m. UTC
Add a means to avoid configuring a device when needed. Add an explanation
of why this is useful to the binding file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++
 drivers/pci/pci-uclass.c                 |  2 ++
 2 files changed, 26 insertions(+)

Comments

Bin Meng Feb. 8, 2020, 3:15 p.m. UTC | #1
Hi Simon,

On Mon, Jan 27, 2020 at 1:08 PM Simon Glass <sjg@chromium.org> wrote:
>
> Add a means to avoid configuring a device when needed. Add an explanation
> of why this is useful to the binding file.
>

Does disabling CONFIG_PCI_PNP not help?

> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++
>  drivers/pci/pci-uclass.c                 |  2 ++
>  2 files changed, 26 insertions(+)
>

Regards,
Bin
Simon Glass Feb. 8, 2020, 3:50 p.m. UTC | #2
Hi Bin,

On Sat, 8 Feb 2020 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Simon,
>
> On Mon, Jan 27, 2020 at 1:08 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > Add a means to avoid configuring a device when needed. Add an explanation
> > of why this is useful to the binding file.
> >
>
> Does disabling CONFIG_PCI_PNP not help?

That is for all devices. Here we just want the UART to stay where it
is so that we can debug serial drivers, FSP-S, etc. If the UART moves
then any output after that hangs the machine until we reinit the
serial driver.

>
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++
> >  drivers/pci/pci-uclass.c                 |  2 ++
> >  2 files changed, 26 insertions(+)
> >

Regards,
SImon
Bin Meng Feb. 8, 2020, 3:54 p.m. UTC | #3
Hi Simon,

On Sat, Feb 8, 2020 at 11:51 PM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Sat, 8 Feb 2020 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Simon,
> >
> > On Mon, Jan 27, 2020 at 1:08 PM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Add a means to avoid configuring a device when needed. Add an explanation
> > > of why this is useful to the binding file.
> > >
> >
> > Does disabling CONFIG_PCI_PNP not help?
>
> That is for all devices. Here we just want the UART to stay where it
> is so that we can debug serial drivers, FSP-S, etc. If the UART moves
> then any output after that hangs the machine until we reinit the
> serial driver.

OK, I think this is for debugging purpose, right? As you must have get
Coral boot for some time, and this is only for retaining the console
debug output?

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Regards,
Bin
Simon Glass Feb. 8, 2020, 4:07 p.m. UTC | #4
Hi Bin,

On Sat, 8 Feb 2020 at 08:54, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Simon,
>
> On Sat, Feb 8, 2020 at 11:51 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Bin,
> >
> > On Sat, 8 Feb 2020 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > >
> > > Hi Simon,
> > >
> > > On Mon, Jan 27, 2020 at 1:08 PM Simon Glass <sjg@chromium.org> wrote:
> > > >
> > > > Add a means to avoid configuring a device when needed. Add an explanation
> > > > of why this is useful to the binding file.
> > > >
> > >
> > > Does disabling CONFIG_PCI_PNP not help?
> >
> > That is for all devices. Here we just want the UART to stay where it
> > is so that we can debug serial drivers, FSP-S, etc. If the UART moves
> > then any output after that hangs the machine until we reinit the
> > serial driver.
>
> OK, I think this is for debugging purpose, right? As you must have get
> Coral boot for some time, and this is only for retaining the console
> debug output?

Sort-of, but I've actually left it enabled. The problem is that if you
get an error or any debug output very early after relocation in
U-Boot, it hangs. I feel it is quite confusing for people to add a bit
of debugging and have it crash.

Admittedly there is a very small window where this happens (roughly
between arch_fsp_init_r() returning and initr_serial() being called.
But i found it pretty annoying.

What do you think?

Also I'd like to change it to suppress console output when it is not
allowed (and print a warning later), but haven't tried that yet.

>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>
> Regards,
> Bin
Bin Meng Feb. 8, 2020, 4:22 p.m. UTC | #5
Hi Simon,

On Sun, Feb 9, 2020 at 12:07 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Sat, 8 Feb 2020 at 08:54, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Simon,
> >
> > On Sat, Feb 8, 2020 at 11:51 PM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Hi Bin,
> > >
> > > On Sat, 8 Feb 2020 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > > >
> > > > Hi Simon,
> > > >
> > > > On Mon, Jan 27, 2020 at 1:08 PM Simon Glass <sjg@chromium.org> wrote:
> > > > >
> > > > > Add a means to avoid configuring a device when needed. Add an explanation
> > > > > of why this is useful to the binding file.
> > > > >
> > > >
> > > > Does disabling CONFIG_PCI_PNP not help?
> > >
> > > That is for all devices. Here we just want the UART to stay where it
> > > is so that we can debug serial drivers, FSP-S, etc. If the UART moves
> > > then any output after that hangs the machine until we reinit the
> > > serial driver.
> >
> > OK, I think this is for debugging purpose, right? As you must have get
> > Coral boot for some time, and this is only for retaining the console
> > debug output?
>
> Sort-of, but I've actually left it enabled. The problem is that if you
> get an error or any debug output very early after relocation in
> U-Boot, it hangs. I feel it is quite confusing for people to add a bit
> of debugging and have it crash.
>
> Admittedly there is a very small window where this happens (roughly
> between arch_fsp_init_r() returning and initr_serial() being called.
> But i found it pretty annoying.
>
> What do you think?
>

Sounds good to me for leaving it enabled by default.

> Also I'd like to change it to suppress console output when it is not
> allowed (and print a warning later), but haven't tried that yet.
>

Regards,
Bin
diff mbox series

Patch

diff --git a/doc/device-tree-bindings/pci/x86-pci.txt b/doc/device-tree-bindings/pci/x86-pci.txt
index 3aa5bd9a46..62b29a4e36 100644
--- a/doc/device-tree-bindings/pci/x86-pci.txt
+++ b/doc/device-tree-bindings/pci/x86-pci.txt
@@ -10,6 +10,17 @@  Optional properties:
 	configuration in TPL/SPL to reduce code size and boot time, since these
 	phases only know about a small subset of PCI devices.
 
+For PCI devices the following optional property is available:
+
+- pci,no-autoconfig : Don't automatically configure this PCI device at all.
+	This is used when the device is statically configured and must maintain
+	this same config throughout the boot process. An example is a serial
+	UART being used to debug PCI configuration, since reconfiguring it stops
+	the UART from working until the driver is re-probed, and this can cause
+	output to be lost. This should not generally be used in production code,
+	although it is often harmless.
+
+
 Example:
 
 pci {
@@ -21,4 +32,17 @@  pci {
 		0x42000000 0x0 0xb0000000 0xb0000000 0 0x10000000
 		0x01000000 0x0 0x1000 0x1000 0 0xefff>;
 	u-boot,skip-auto-config-until-reloc;
+
+
+	serial: serial@18,2 {
+		reg = <0x0200c210 0 0 0 0>;
+		u-boot,dm-pre-reloc;
+		compatible = "intel,apl-ns16550";
+		early-regs = <0xde000000 0x20>;
+		reg-shift = <2>;
+		clock-frequency = <1843200>;
+		current-speed = <115200>;
+		acpi,name = "URT3";
+		pci,no-autoconfig;
+	};
 };
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index bb272b67a1..f5f713fdf4 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -535,6 +535,8 @@  int pci_auto_config_devices(struct udevice *bus)
 		int ret;
 
 		debug("%s: device %s\n", __func__, dev->name);
+		if (dev_read_bool(dev, "pci,no-autoconfig"))
+			continue;
 		ret = dm_pciauto_config_device(dev);
 		if (ret < 0)
 			return ret;