pci: Do not access Freescale PCI controllers BARs registers
cover pci: Do not access Freescale PCI controllers BARs registers
Freescale PCI and PCIe controllers export in config space in BARs offset for BDF address 00:00.0 internal controller registers, instead of BAR registers. Avoid access to these registers to prevent overwriting them.
Fixes autoconfiguration of PCI and PCIe devices on Freescale PowerPC platforms.
Pali Rohár (3):
pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0
pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
pci: auto: Remove PCI_CLASS_PROCESSOR_POWERPC autoconfig case
drivers/pci/pci_auto.c | 4 ---- drivers/pci/pci_mpc85xx.c | 12 ++++++++++++ drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0
At BDF address 00:00.0 is fictional device which PCI configuration header is for configuring mpc85xx PCI controller itself. PCI config space of this device has ATMU inbound registers on position of PCI BARs. Trying to do PCI auto configuration of this device cause rewriting ATMU inbound registers. To avoid it, do not allow overwriting registers at BARs positions. And because this device does not have any PCI memory, return zeros when trying to read PCI BARs config space registers. It signals to auto configuration tool to not allocate any PCI memory for this device.
This information is taken from MPC8544E Reference Manual, sections 17.3.1.3, 17.3.1.1.1, 17.3.2 and 17.3.2.11. Available at NXP website:
https://www.nxp.com/docs/en/reference-manual/MPC8544ERM.pdf
--- drivers/pci/pci_mpc85xx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/pci/pci_mpc85xx.c +12 -0
@@ -27,6 +27,13 @@ static int mpc85xx_pci_dm_read_config(const struct udevice *dev, pci_dev_t bdf,return 0 ; } +/* Skip mpc85xx PCI controller's ATMU inbound registers */ +if (PCI_BUS (bdf) ==0 &&PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) >=PCI_BASE_ADDRESS_0 && (offset & ~3 ) <=PCI_BASE_ADDRESS_5 ) { + *value =0 ; +return 0 ; + } + addr =PCI_CONF1_ADDRESS (PCI_BUS (bdf),PCI_DEV (bdf),PCI_FUNC (bdf), offset);out_be32 (priv->cfg_addr, addr);sync ();
@@ -56,6 +63,11 @@ static int mpc85xx_pci_dm_write_config(struct udevice *dev, pci_dev_t bdf,if (offset >0xff )return 0 ; +/* Skip mpc85xx PCI controller's ATMU inbound registers */ +if (PCI_BUS (bdf) ==0 &&PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) >=PCI_BASE_ADDRESS_0 && (offset & ~3 ) <=PCI_BASE_ADDRESS_5 ) +return 0 ; + addr =PCI_CONF1_ADDRESS (PCI_BUS (bdf),PCI_DEV (bdf),PCI_FUNC (bdf), offset);out_be32 (priv->cfg_addr, addr);sync ();
Signature · 1 line
2.20.1
Re: [PATCH u-boot 1/3] pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0
Hello Pali,
Quoted 9 lines · Pali Rohár
At BDF address 00:00.0 is fictional device which PCI configuration header is for configuring mpc85xx PCI controller itself. PCI config space of this device has ATMU inbound registers on position of PCI BARs. Trying to do PCI auto configuration of this device cause rewriting ATMU inbound registers. To avoid it, do not allow overwriting registers at BARs positions. And because this device does not have any PCI memory, return zeros when trying to read PCI BARs config space registers. It signals to auto configuration tool to not allocate any PCI memory for this device.
Quoted 8 lines
This information is taken from MPC8544E Reference Manual, sections 17.3.1.3, 17.3.1.1.1, 17.3.2 and 17.3.2.11. Available at NXP website:
https://www.nxp.com/docs/en/reference-manual/MPC8544ERM.pdfSigned-off-by Pali Rohár <[email protected]>--- drivers/pci/pci_mpc85xx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Tested on the socrates board, it fixes the problem:
PCI: Failed autoconfig bar 18
PCI: Failed autoconfig bar 20
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Re: [PATCH u-boot 1/3] pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0
In reply to Pali RohárQuoted 9 lines · Pali Rohár
At BDF address 00:00.0 is fictional device which PCI configuration header is for configuring mpc85xx PCI controller itself. PCI config space of this device has ATMU inbound registers on position of PCI BARs. Trying to do PCI auto configuration of this device cause rewriting ATMU inbound registers. To avoid it, do not allow overwriting registers at BARs positions. And because this device does not have any PCI memory, return zeros when trying to read PCI BARs config space registers. It signals to auto configuration tool to not allocate any PCI memory for this device.
Quoted 7 lines
This information is taken from MPC8544E Reference Manual, sections 17.3.1.3, 17.3.1.1.1, 17.3.2 and 17.3.2.11. Available at NXP website:
https://www.nxp.com/docs/en/reference-manual/MPC8544ERM.pdfSigned-off-by Pali Rohár <[email protected]>Reviewed-by Heiko Schocher <[email protected]>Tested-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH 2/3 pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
In reply to Pali RohárFreescale PCIe Root Port has PEXCSRBAR register at position of PCI BAR0. PCIe Root Port does not have any PCIe memory, so returns zero when trying to read from PCIe Root Port BAR0 and ignore any writes.
--- drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/pci/pcie_fsl.c +14 -0
@@ -58,6 +58,14 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf,return 0 ; } +/* Skip Freescale PCIe controller's PEXCSRBAR register */ +if (PCI_BUS (bdf) -dev_seq (bus) ==0 && +PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) ==PCI_BASE_ADDRESS_0 ) { + *value =0 ; +return 0 ; + } + val =PCI_CONF1_EXT_ADDRESS (PCI_BUS (bdf) -dev_seq (bus),PCI_DEV (bdf),PCI_FUNC (bdf), offset);
@@ -95,6 +103,12 @@ static int fsl_pcie_write_config(struct udevice *bus, pci_dev_t bdf,if (fsl_pcie_addr_valid (pcie, bdf))return 0 ; +/* Skip Freescale PCIe controller's PEXCSRBAR register */ +if (PCI_BUS (bdf) -dev_seq (bus) ==0 && +PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) ==PCI_BASE_ADDRESS_0 ) +return 0 ; + val =PCI_CONF1_EXT_ADDRESS (PCI_BUS (bdf) -dev_seq (bus),PCI_DEV (bdf),PCI_FUNC (bdf), offset);
Signature · 1 line
2.20.1
Re: [PATCH u-boot 2/3] pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
Hello Plai,
Quoted 8 lines · Pali Rohár
Freescale PCIe Root Port has PEXCSRBAR register at position of PCI BAR0. PCIe Root Port does not have any PCIe memory, so returns zero when trying to read from PCIe Root Port BAR0 and ignore any writes.
Signed-off-by Pali Rohár <[email protected]>--- drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Re: [PATCH u-boot 2/3] pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
In reply to Pali RohárQuoted 19 lines · Pali Rohár
Freescale PCIe Root Port has PEXCSRBAR register at position of PCI BAR0. PCIe Root Port does not have any PCIe memory, so returns zero when trying to read from PCIe Root Port BAR0 and ignore any writes.
Signed-off-by Pali Rohár <[email protected]>Reviewed-by Heiko Schocher <[email protected]>--- drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/pci/pcie_fsl.c +1
-0@@ -58,6 +58,14 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf,return 0 ; } +/* Skip Freescale PCIe controller's PEXCSRBAR register */
drivers/pci/pcie_fsl.c static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, · line 71
Quoted 10 lines
drivers/pci/pcie_fsl.c +7
-0+if (PCI_BUS (bdf) -dev_seq (bus) ==0 && +PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) ==PCI_BASE_ADDRESS_0 ) { + *value =0 ; +return 0 ; + } + val =PCI_CONF1_EXT_ADDRESS (PCI_BUS (bdf) -dev_seq (bus),PCI_DEV (bdf),PCI_FUNC (bdf), offset);
There is no "value" in this function, only "val", which in turn is local to the function, and *valuep which we are passed by the caller, please re-work and send v2, thanks.
Signature · 1 line
Tom
PATCH v2 1/1 pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
Freescale PCIe Root Port has PEXCSRBAR register at position of PCI BAR0. PCIe Root Port does not have any PCIe memory, so returns zero when trying to read from PCIe Root Port BAR0 and ignore any writes.
--- drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/pci/pcie_fsl.c +14 -0
@@ -58,6 +58,14 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf,return 0 ; } +/* Skip Freescale PCIe controller's PEXCSRBAR register */ +if (PCI_BUS (bdf) -dev_seq (bus) ==0 && +PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) ==PCI_BASE_ADDRESS_0 ) { + *valuep =0 ; +return 0 ; + } + val =PCI_CONF1_EXT_ADDRESS (PCI_BUS (bdf) -dev_seq (bus),PCI_DEV (bdf),PCI_FUNC (bdf), offset);
@@ -95,6 +103,12 @@ static int fsl_pcie_write_config(struct udevice *bus, pci_dev_t bdf,if (fsl_pcie_addr_valid (pcie, bdf))return 0 ; +/* Skip Freescale PCIe controller's PEXCSRBAR register */ +if (PCI_BUS (bdf) -dev_seq (bus) ==0 && +PCI_DEV (bdf) ==0 &&PCI_FUNC (bdf) ==0 && + (offset & ~3 ) ==PCI_BASE_ADDRESS_0 ) +return 0 ; + val =PCI_CONF1_EXT_ADDRESS (PCI_BUS (bdf) -dev_seq (bus),PCI_DEV (bdf),PCI_FUNC (bdf), offset);
Signature · 1 line
2.20.1
Re: [PATCH v2 u-boot] pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
Quoted 5 lines · Pali Rohár
Freescale PCIe Root Port has PEXCSRBAR register at position of PCI BAR0. PCIe Root Port does not have any PCIe memory, so returns zero when trying to read from PCIe Root Port BAR0 and ignore any writes.
Signed-off-by Pali Rohár <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
PATCH 3/3 pci: auto: Remove PCI_CLASS_PROCESSOR_POWERPC autoconfig case
In reply to Pali RohárPCI autoconfig case for PCI_CLASS_PROCESSOR_POWERPC just prints debug message and then calls autoconfig setup code like for any other standard endpoint device. We do not need special debug message for it, so remove this case and handle PCI_CLASS_PROCESSOR_POWERPC via default code path.
--- drivers/pci/pci_auto.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/pci_auto.c +0 -4
@@ -580,10 +580,6 @@ int dm_pciauto_config_device(struct udevice *dev)break ;#endif -case PCI_CLASS_PROCESSOR_POWERPC :/* an agent or end-point */ -debug ("PCI AutoConfig: Found PowerPC device\n" ); -/* fall through */ -default :dm_pciauto_setup_device (dev, pci_mem, pci_prefetch, pci_io);break ;
Signature · 1 line
2.20.1
Re: [PATCH u-boot 3/3] pci: auto: Remove PCI_CLASS_PROCESSOR_POWERPC autoconfig case
Hello Pali,
Quoted 9 lines · Pali Rohár
PCI autoconfig case for
PCI_CLASS_PROCESSOR_POWERPCjust prints debug message and then calls autoconfig setup code like for any other standard endpoint device. We do not need special debug message for it, so remove this case and handlePCI_CLASS_PROCESSOR_POWERPCvia default code path.Signed-off-by Pali Rohár <[email protected]>--- drivers/pci/pci_auto.c | 4 ---- 1 file changed, 4 deletions(-)
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Re: [PATCH u-boot 3/3] pci: auto: Remove PCI_CLASS_PROCESSOR_POWERPC autoconfig case
In reply to Pali RohárQuoted 7 lines · Pali Rohár
PCI autoconfig case for
PCI_CLASS_PROCESSOR_POWERPCjust prints debug message and then calls autoconfig setup code like for any other standard endpoint device. We do not need special debug message for it, so remove this case and handlePCI_CLASS_PROCESSOR_POWERPCvia default code path.Signed-off-by Pali Rohár <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
Hello Pali,
Quoted 12 lines · Pali Rohár
Freescale PCI and PCIe controllers export in config space in BARs offset for BDF address 00:00.0 internal controller registers, instead of BAR registers. Avoid access to these registers to prevent overwriting them.
Fixes autoconfiguration of PCI and PCIe devices on Freescale PowerPC platforms.
Pali Rohár (3):
pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0
pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
pci: auto: RemovePCI_CLASS_PROCESSOR_POWERPCautoconfig case
Quoted 4 lines
drivers/pci/pci_auto.c | 4 ---- drivers/pci/pci_mpc85xx.c | 12 ++++++++++++ drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-)
Many thanks for this series!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Quoted 15 lines · On Friday 21 April 2023 05:54:29 Heiko Schocher wrote:
Hello Pali,
Quoted 12 lines · Pali Rohár
Freescale PCI and PCIe controllers export in config space in BARs offset for BDF address 00:00.0 internal controller registers, instead of BAR registers. Avoid access to these registers to prevent overwriting them.
Fixes autoconfiguration of PCI and PCIe devices on Freescale PowerPC platforms.
Pali Rohár (3):
pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0
pci: fsl: Do not access PCI BAR0 register of PCIe Root Port
pci: auto: RemovePCI_CLASS_PROCESSOR_POWERPCautoconfig case
Quoted 6 lines
Quoted 4 lines
drivers/pci/pci_auto.c | 4 ---- drivers/pci/pci_mpc85xx.c | 12 ++++++++++++ drivers/pci/pcie_fsl.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-)Many thanks for this series!
Ok, is something more needed?
Quoted 6 lines
bye,
HeikoSignature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]