LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: scottwood@freescale.com, linuxppc-dev@ozlabs.org
Subject: Re: mpc8xxx PCIe hotplug needs fixing, some clues ..
Date: Fri, 20 Jul 2012 13:53:10 -0500	[thread overview]
Message-ID: <EC6BFBB7-DF3B-402A-ACB6-51546C1B6CC9@kernel.crashing.org> (raw)
In-Reply-To: <OFDEF2A72A.01F68496-ONC1257A41.0025B7CE-C1257A41.0028192F@transmode.se>


On Jul 20, 2012, at 2:17 AM, Joakim Tjernlund wrote:

>=20
> Hi Guys
>=20
> I see that you have been hacking Freescale PCI before so I send this =
to you(and the list)
>=20
> We are using PCIe(as RC) on P2010(basically a mpc85xx) and have PCI =
device that
> started from user space (needs advance clock conf) so when linux boots =
there is
> no device at all.
> Trying to "hotplug" the device after it is enabled fails, no amount of =
recan/remove using
> either fake or real hotplug makes a difference.
>=20
> I found the cause eventually but I can't fix it properly as I known =
almost nothing about PCI.
> Cause:
> indirect_pci.c:indirect_read_config() tests for if =
(hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK)
> and returns  PCIBIOS_DEVICE_NOT_FOUND
>=20
> PPC_INDIRECT_TYPE_NO_PCIE_LINK get set by fsl_pci.c (look for =
fsl_pcie_check_link) but is never cleared.
> Clearing it as appropriate makes a small difference. If you
> remove the RC and do a few of rescan's then the device appears.
>=20
> Hacking some more, like so:
>=20
> int fsl_pcie_check_link(struct pci_controller *hose)
> {
> 	u32 val;
>=20
> 	early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
> 	hose->indirect_type |=3D PPC_INDIRECT_TYPE_NO_PCIE_LINK;
> 	if (val < PCIE_LTSSM_L0)
> 		return 1;
> 	hose->indirect_type &=3D ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
> 	return 0;
> }
> and then using it carefully(it is easy to make linux hang) in =
indirect_read_config():
> indirect_read_config(struct pci_bus *bus, unsigned int devfn, int =
offset,
> 		     int len, u32 *val)
> {
> 	struct pci_controller *hose =3D pci_bus_to_host(bus);
> 	volatile void __iomem *cfg_data;
> 	u8 cfg_type =3D 0;
> 	u32 bus_no, reg;
>=20
> 	if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK) {
> 		if (bus->number !=3D hose->first_busno ||
> 		    devfn !=3D 0) {
> 			fsl_pcie_check_link(hose);
> 			return PCIBIOS_DEVICE_NOT_FOUND;
> 		}
> 	}
>=20
> Now it works, just one rescan and the device appears!
> This is a hack, I don't known what other trouble it can cause, I hope =
you can
> sort this out.

How are you forcing the re-scan?  We can see if we can add a re-check of =
the link state in that flow somewhere.

Can you do a dump_stack() or something to get a call chain?

- k=

  reply	other threads:[~2012-07-20 18:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20  7:17 mpc8xxx PCIe hotplug needs fixing, some clues Joakim Tjernlund
2012-07-20 18:53 ` Kumar Gala [this message]
2012-07-21 16:11   ` Joakim Tjernlund
2012-07-21 17:00   ` Joakim Tjernlund
     [not found]   ` <OF85435159.0952793A-ONC1257A42.0058090C-C1257A42.0058F2A6@LocalDomain>
2012-07-23 16:45     ` Joakim Tjernlund
2012-08-06  9:39       ` Joakim Tjernlund

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=EC6BFBB7-DF3B-402A-ACB6-51546C1B6CC9@kernel.crashing.org \
    --to=galak@kernel.crashing.org \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=scottwood@freescale.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